This repository was archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
871c14f
commit 57c9b0d
Showing
5 changed files
with
26 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { useEffect } from 'react'; | ||
import { handleNavigateTop } from '../utils/handle-scroll'; | ||
|
||
const useKeyDownListener = (tableBodyWrapperRef, tableContainerRef, focusedCellCoord, rootElement, totalsPosition) => { | ||
const useKeyDownListener = (tableBodyWrapperRef, focusedCellCoord, rootElement, totalsPosition) => { | ||
useEffect(() => { | ||
const memoedContainer = tableBodyWrapperRef.current; | ||
if (!memoedContainer) return undefined; | ||
|
||
const keyDownHandler = (evt) => | ||
evt.key === 'ArrowUp' && handleNavigateTop({ tableContainerRef, focusedCellCoord, rootElement, totalsPosition }); | ||
memoedContainer.addEventListener('keydown', keyDownHandler); | ||
evt.key === 'ArrowUp' && handleNavigateTop({ focusedCellCoord, rootElement, totalsPosition }); | ||
memoedContainer.addEventListener('keyup', keyDownHandler); | ||
|
||
return () => { | ||
memoedContainer.removeEventListener('keydown', keyDownHandler); | ||
memoedContainer.removeEventListener('keyup', keyDownHandler); | ||
}; | ||
}, [tableBodyWrapperRef, tableContainerRef, focusedCellCoord, rootElement, totalsPosition]); | ||
}, [tableBodyWrapperRef, focusedCellCoord, rootElement, totalsPosition]); | ||
}; | ||
|
||
export default useKeyDownListener; |
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