scroll on mobile field click

pull/440/head
Pete Matsyburka 9 months ago
parent 071f187605
commit 9ff41a0c4a

@ -31,7 +31,7 @@
:with-label="withLabel && !withFieldPlaceholder && step.length < 2" :with-label="withLabel && !withFieldPlaceholder && step.length < 2"
:is-value-set="step.some((f) => f.uuid in values)" :is-value-set="step.some((f) => f.uuid in values)"
:attachments-index="attachmentsIndex" :attachments-index="attachmentsIndex"
@click="$emit('focus-step', stepIndex)" @click="[$emit('focus-step', stepIndex), maybeScrollOnClick(field, area)]"
/> />
</Teleport> </Teleport>
</template> </template>
@ -109,6 +109,14 @@ export default {
areaRefs: [] areaRefs: []
} }
}, },
computed: {
isMobileContainer () {
const root = this.$root.$el.parentNode.getRootNode()
const container = root.body || root.querySelector('div')
return container.style.overflow === 'hidden'
}
},
beforeUpdate () { beforeUpdate () {
this.areaRefs = [] this.areaRefs = []
}, },
@ -121,14 +129,16 @@ export default {
this.scrollIntoArea(field.areas[0]) this.scrollIntoArea(field.areas[0])
} }
}, },
maybeScrollOnClick (field, area) {
if (['text', 'number', 'cells'].includes(field.type) && this.isMobileContainer) {
this.scrollIntoArea(area)
}
},
scrollIntoArea (area) { scrollIntoArea (area) {
const areaRef = this.areaRefs.find((a) => a.area === area) const areaRef = this.areaRefs.find((a) => a.area === area)
if (areaRef) { if (areaRef) {
const root = this.$root.$el.parentNode.getRootNode() if (this.isMobileContainer) {
const container = root.body || root.querySelector('div')
if (container.style.overflow === 'hidden') {
this.scrollInContainer(areaRef.$el) this.scrollInContainer(areaRef.$el)
} else { } else {
const targetRect = areaRef.$refs.scrollToElem.getBoundingClientRect() const targetRect = areaRef.$refs.scrollToElem.getBoundingClientRect()

Loading…
Cancel
Save