Skip to content

Commit

Permalink
update Toast dismiss timing (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbasuil authored Jan 3, 2024
1 parent dfd3012 commit 2683df6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Alert/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const getAlertIcon = (type) => {
}
};

const AUTO_DISMISS_TIMEOUT = 5000;
const AUTO_DISMISS_TIMEOUT_SUCCESS = 3000;
const AUTO_DISMISS_TIMEOUT_DEFAULT = 5000;

const getAlertClassName = (type) => {
if (!Object.values(MessageTypes).includes(type)) {
Expand All @@ -68,12 +69,14 @@ function Alert(props) {
useEffect(() => {
let timeout;
if (autoDismiss) {
timeout = setTimeout(() => (onDismiss(id)), AUTO_DISMISS_TIMEOUT);
timeout = setTimeout(() => (onDismiss(id)),
props.type === MessageTypes.SUCCESS ?
AUTO_DISMISS_TIMEOUT_SUCCESS : AUTO_DISMISS_TIMEOUT_DEFAULT);
}
return () => {
clearTimeout(timeout);
};
}, [autoDismiss, onDismiss, id]);
}, [autoDismiss, onDismiss, id, props.type]);

return (
<div
Expand Down

0 comments on commit 2683df6

Please sign in to comment.