-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Snackbar to be persistent #426
Conversation
Signed-off-by: jamal-khey <myjamal89@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're trying to just extend a bit the notistack API here with our snackInfo, snackWarn, etc.. methods, so it would be nice to not limit it. If so, it wouldn't require any dev to add the persist behavior as it is already in the notistack API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really on your dev but the makeSnackbar method kind of mixes the logic of building the message and the one that just enqueue the message, maybe you could split them to make it more readable.
Something like that for the enqueue logic
const enqueue = useCallback(
(variant: BaseVariant, snackInputs: SnackInputs) => {
const message = makeMessage(intlRef, snackInputs);
if (message !== undefined) {
enqueueSnackbar(message, {
...snackInputs,
variant,
style: { whiteSpace: 'pre-line' },
});
}
},
[enqueueSnackbar, intlRef]
);
And then you keep the makeMessage with the current message logic.
Signed-off-by: jamal-khey <myjamal89@gmail.com>
demo/src/app.jsx
Outdated
<Button | ||
variant="contained" | ||
color="info" | ||
style={{ float: 'left', margin: '5px' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make style button sx={style.button}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This pull request adds the ability to make Snackbar messages persistent. Previously, Snackbar messages would disappear after a certain amount of time, but now they can be set to stay on the screen until dismissed by the user.