File tree Expand file tree Collapse file tree
src/pages/iou/SplitList/useHandleInputFocus Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { useCallback } from 'react' ;
12import type { SplitListItemType } from '@components/SelectionList/ListItem/types' ;
23import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode' ;
34import type UseHandleInputFocusProps from './types' ;
45
56function useHandleInputFocus ( { listRef} : UseHandleInputFocusProps ) {
67 const isInLandscapeMode = useIsInLandscapeMode ( ) ;
78
8- return ( item : SplitListItemType ) => {
9- if ( ! listRef . current || isInLandscapeMode ) {
10- return ;
11- }
12- listRef . current ?. scrollToFocusedInput ( item ) ;
13- } ;
9+ return useCallback (
10+ ( item : SplitListItemType ) => {
11+ if ( ! listRef . current || isInLandscapeMode ) {
12+ return ;
13+ }
14+ listRef . current ?. scrollToFocusedInput ( item ) ;
15+ } ,
16+ [ listRef , isInLandscapeMode ] ,
17+ ) ;
1418}
1519
1620export default useHandleInputFocus ;
Original file line number Diff line number Diff line change 1+ import { useCallback } from 'react' ;
12import type { SplitListItemType } from '@components/SelectionList/ListItem/types' ;
23import type UseHandleInputFocusProps from './types' ;
34
45function useHandleInputFocus ( { listRef} : UseHandleInputFocusProps ) {
5- return ( item : SplitListItemType ) => {
6- if ( ! listRef . current ) {
7- return ;
8- }
9- listRef . current ?. scrollToFocusedInput ( item ) ;
10- } ;
6+ return useCallback (
7+ ( item : SplitListItemType ) => {
8+ if ( ! listRef . current ) {
9+ return ;
10+ }
11+ listRef . current ?. scrollToFocusedInput ( item ) ;
12+ } ,
13+ [ listRef ] ,
14+ ) ;
1115}
1216
1317export default useHandleInputFocus ;
You can’t perform that action at this time.
0 commit comments