Skip to content

Commit

Permalink
πŸ› Snackbar: check if "open" before autohide timer (#3241)
Browse files Browse the repository at this point in the history
  • Loading branch information
oddvernes authored Jan 26, 2024
1 parent fb4a5c4 commit f3302d6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/eds-core-react/src/components/Snackbar/Snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ export const Snackbar = forwardRef<HTMLDivElement, SnackbarProps>(

useEffect(() => {
setVisible(open)

timer.current = setTimeout(() => {
setVisible(false)

if (onClose) {
onClose()
}
}, autoHideDuration)

if (open) {
timer.current = setTimeout(() => {
setVisible(false)
if (onClose) {
onClose()
}
}, autoHideDuration)
}
return () => clearTimeout(timer.current)
}, [open, autoHideDuration, setVisible, onClose])

Expand Down

0 comments on commit f3302d6

Please sign in to comment.