Skip to content

Commit

Permalink
fix(SnackAlert): prevent auto-closing of warning and error alerts
Browse files Browse the repository at this point in the history
Remove autoHideDuration property to ensure alerts remain visible until user closes them manually.
  • Loading branch information
JE1999 committed May 15, 2024
1 parent 2968c64 commit 4cc1c4d
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 4cc1c4d

Please sign in to comment.