Skip to content

Commit

Permalink
Merge pull request #55701 from bernhardoj/fix/55601-list-scrolls-to-t…
Browse files Browse the repository at this point in the history
…op-on-open

Fix currency list scrolls to top when quickly scrolls down after open the page
  • Loading branch information
carlosmiceli authored Jan 24, 2025
2 parents 9043b14 + 13dad8b commit 5f08ac2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useSyncFocus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ScreenWrapperStatusContext} from '@components/ScreenWrapper';
* When the user navigates through the app using the arrows and then the tab button, the focus on the element and the native focus of the browser differs.
* To maintain consistency when an element is focused in the app, the focus() method is additionally called on the focused element to eliminate the difference between native browser focus and application focus.
*/
const useSyncFocus = (ref: RefObject<View>, isFocused: boolean, shouldSyncFocus = true) => {
const useSyncFocus = (ref: RefObject<View | HTMLElement>, isFocused: boolean, shouldSyncFocus = true) => {
// this hook can be used outside ScreenWrapperStatusContext (eg. in Popovers). So we to check if the context is present.
// If we are outside context we don't have to look at transition status
const contextValue = useContext(ScreenWrapperStatusContext);
Expand All @@ -20,7 +20,7 @@ const useSyncFocus = (ref: RefObject<View>, isFocused: boolean, shouldSyncFocus
return;
}

ref.current?.focus();
ref.current?.focus({preventScroll: true});
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [didScreenTransitionEnd, isFocused, ref]);
};
Expand Down

0 comments on commit 5f08ac2

Please sign in to comment.