🚸 Improve auto scroll behavior

Now only based on bottom of last element if it is in view
This commit is contained in:
Baptiste Arnaud
2024-04-24 17:40:27 +02:00
parent 873ba0bfda
commit a7fc41316c
13 changed files with 22 additions and 18 deletions

View File

@@ -18,7 +18,7 @@ export const Buttons = (props: Props) => {
const [filteredItems, setFilteredItems] = createSignal(props.defaultItems)
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
})
const handleClick = (itemIndex: number) =>

View File

@@ -19,7 +19,7 @@ export const MultipleChoicesForm = (props: Props) => {
const [selectedItemIds, setSelectedItemIds] = createSignal<string[]>([])
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
})
const handleClick = (itemId: string) => {

View File

@@ -33,7 +33,7 @@ export const EmailInput = (props: Props) => {
}
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
window.addEventListener('message', processIncomingEvent)
})

View File

@@ -36,7 +36,7 @@ export const NumberInput = (props: NumberInputProps) => {
}
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
window.addEventListener('message', processIncomingEvent)
})

View File

@@ -90,7 +90,7 @@ export const PhoneInput = (props: PhoneInputProps) => {
}
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
window.addEventListener('message', processIncomingEvent)
})

View File

@@ -22,7 +22,7 @@ export const MultiplePictureChoice = (props: Props) => {
const [totalLoadedImages, setTotalLoadedImages] = createSignal(0)
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
})
const handleClick = (itemId: string) => {

View File

@@ -18,7 +18,7 @@ export const SinglePictureChoice = (props: Props) => {
const [totalLoadedImages, setTotalLoadedImages] = createSignal(0)
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef) inputRef.focus({ preventScroll: true })
})
const handleClick = (itemIndex: number) => {

View File

@@ -40,7 +40,10 @@ export const TextInput = (props: Props) => {
}
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef)
inputRef.focus({
preventScroll: true,
})
window.addEventListener('message', processIncomingEvent)
})

View File

@@ -39,7 +39,10 @@ export const UrlInput = (props: Props) => {
}
onMount(() => {
if (!isMobile() && inputRef) inputRef.focus()
if (!isMobile() && inputRef)
inputRef.focus({
preventScroll: true,
})
window.addEventListener('message', processIncomingEvent)
})