Skip to content

Commit

Permalink
Fix snackbar changing color when spanmming
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel-Therrien-Beslogic committed Dec 3, 2024
1 parent 1b8c3dc commit cca21de
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions canopeum_frontend/src/components/context/SnackbarContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,23 @@ const SnackbarContextProvider: FunctionComponent<{ readonly children?: ReactNode
}, [snackPack, messageInfo, open])

const handleClose = (_event: Event | SyntheticEvent, reason?: string) => {
if (reason === 'clickaway') {
return
}
if (reason === 'clickaway') return
setOpen(false)
}

const handleExited = () => {
setSnackbarAlertOptions(undefined)
setMessageInfo(undefined)
}

const openAlertSnackbar = useCallback((message: string, options?: SnackbarAlertOptions) => {
setSnackbarAlertOptions(options)
setSnackPack(previous => [...previous, { message, key: Date.now() }])
}, [setSnackPack, setSnackbarAlertOptions])

const context = useMemo<ISnackbarContext>(() => (
{
openAlertSnackbar,
}
), [openAlertSnackbar])
const context = useMemo<ISnackbarContext>(() => ({ openAlertSnackbar }), [openAlertSnackbar])

return (
<SnackbarContext.Provider value={context}>
{props.children}

<Snackbar
TransitionProps={{ onExited: handleExited }}
TransitionProps={{ onExited: () => setMessageInfo(undefined) }}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
autoHideDuration={snackbarAlertOptions?.autohideDuration
?? DEFAULT_SNACKBAR_ALERT_OPTIONS.autohideDuration}
Expand All @@ -100,6 +89,5 @@ const SnackbarContextProvider: FunctionComponent<{ readonly children?: ReactNode
)
},
)

SnackbarContextProvider.displayName = 'SnackbarContextProvider'
export default SnackbarContextProvider

0 comments on commit cca21de

Please sign in to comment.