Skip to content

Commit

Permalink
fix(SnackAlert): prevent auto-closing of warning and error alerts (#227)
Browse files Browse the repository at this point in the history
Remove autoHideDuration property to ensure alerts remain visible until user closes them manually.

Co-authored-by: Jeffrey Mesa <[email protected]>
  • Loading branch information
JE1999 and JeffreyArt1 authored May 15, 2024
1 parent 826f3e8 commit 3dfd558
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/components/elements/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface SnackbarState {
vertical: 'top' | 'bottom';
horizontal: 'left' | 'center' | 'right';
open: boolean;
duration: number;
content: string;
severity: AlertProps['severity'];
}
Expand Down Expand Up @@ -40,7 +39,6 @@ const SnackAlert: React.FC<SnackAlertProps> = ({ children }) => {
vertical: 'bottom',
horizontal: 'left',
open: false,
duration: 6000,
content: '',
severity: 'success' as AlertProps['severity'],
};
Expand All @@ -62,15 +60,14 @@ const SnackAlert: React.FC<SnackAlertProps> = ({ children }) => {
const AlertSuccess = (text: string = 'Proceso realizado correctamente') =>
handleOpen({ content: text, severity: 'success' });

const { vertical, horizontal, open, severity, content, duration } = snackbar;
const { vertical, horizontal, open, severity, content } = snackbar;

return (
<SnackAlertContext.Provider
value={{ AlertError, AlertWarning, AlertSuccess }}
>
{children}
<Snackbar
autoHideDuration={duration}
anchorOrigin={{ vertical, horizontal }}
open={open}
onClose={handleClose}
Expand Down

0 comments on commit 3dfd558

Please sign in to comment.