-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make autocomplete autoscroll on focus mobile only
We added an on focus autoscroll to the autocomplete fields to stop the dropdown menu being hidden behind the on screen keyboard. This works well on mobile but is annoying on desktop, so this makes the autoscroll only happen on smaller sizes. I also moved the autoscroll functionality into a composable as it's shared between 3 fields. Ticket: https://phabricator.wikimedia.org/T374419
- Loading branch information
Showing
7 changed files
with
52 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/components/shared/form_fields/useAutocompleteScrollIntoViewOnFocus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function useAutocompleteScrollIntoViewOnFocus( target: string, maxWidth: number ): () => void { | ||
return (): void => { | ||
|
||
if ( window.innerWidth > maxWidth ) { | ||
return; | ||
} | ||
|
||
const scrollIntoViewElement = document.getElementById( target ); | ||
if ( scrollIntoViewElement ) { | ||
scrollIntoViewElement.scrollIntoView( { behavior: 'smooth' } ); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters