Skip to content

Commit

Permalink
Merge pull request #212 from EyeSeeTea/refactor/snackbar-keep-on-clic…
Browse files Browse the repository at this point in the history
…kaway

[snackbar] keep open on page clickaway
  • Loading branch information
adrianq authored Aug 4, 2021
2 parents 086de4c + 3d5cb19 commit 889a42d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "git+https://github.com/eyeseetea/d2-ui-components.git"
},
"version": "2.6.6",
"version": "2.6.7-beta.1",
"main": "index.js",
"types": "index.d.ts",
"peerDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion src/snackbar/SnackbarConsumer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ const SnackbarConsumer = () => {
if (!state) throw new Error("Snackbar context has not been defined");
const { isOpen, message, variant, closeSnackbar, autoHideDuration } = state;

function notifyClose(_ev: React.SyntheticEvent<any>, reason: string) {
if (reason !== "clickaway") closeSnackbar();
}

if (!variant || !variantIcon[variant]) {
throw new Error(`Unknown variant: ${variant}`);
}
Expand All @@ -85,7 +89,7 @@ const SnackbarConsumer = () => {
anchorOrigin={anchorOrigin}
open={isOpen}
autoHideDuration={autoHideDuration}
onClose={closeSnackbar}
onClose={notifyClose}
>
<SnackbarContent
className={classes[variant]}
Expand Down

0 comments on commit 889a42d

Please sign in to comment.