Skip to content

Commit

Permalink
Merge pull request #1258 from h3poteto/fix/delay-scroll
Browse files Browse the repository at this point in the history
Fix delay scrolling logic for notification
  • Loading branch information
h3poteto authored Nov 24, 2023
2 parents 9f86cec + 0bcdbd3 commit e865040
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,18 @@ function App() {
useEffect(() => {
if (!highlighted) return
if (!spaceRef.current) return
setTimeout(() => {
const node = document.getElementById(highlighted.id.toString())
if (node) {
scrollLeft(spaceRef.current, node.offsetLeft)
}
}, 500)
const node = document.getElementById(highlighted.id.toString())
if (node) {
scrollLeft(spaceRef.current, node.offsetLeft)
} else {
// Retry to scroll
setTimeout(() => {
const node = document.getElementById(highlighted.id.toString())
if (node) {
scrollLeft(spaceRef.current, node.offsetLeft)
}
}, 500)
}
}, [highlighted])

const handleKeyPress = useCallback(async (event: KeyboardEvent) => {
Expand Down

0 comments on commit e865040

Please sign in to comment.