From 7997eec14c90e99f09f5119abeadc1ee89b7404a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 28 Jul 2024 13:28:52 +0530 Subject: [PATCH] [docs][material-ui][Snackbar] Improve close `reason` type in demos (@sai6855) (#43105) Co-authored-by: sai chand <60743144+sai6855@users.noreply.github.com> Co-authored-by: ZeeshanTamboli --- .../material/components/snackbars/AutohideSnackbar.tsx | 7 +++++-- .../material/components/snackbars/ConsecutiveSnackbars.tsx | 7 +++++-- .../material/components/snackbars/CustomizedSnackbars.tsx | 7 +++++-- docs/data/material/components/snackbars/SimpleSnackbar.tsx | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/data/material/components/snackbars/AutohideSnackbar.tsx b/docs/data/material/components/snackbars/AutohideSnackbar.tsx index 1f1393e26e246a..b5fd1f75e775b0 100644 --- a/docs/data/material/components/snackbars/AutohideSnackbar.tsx +++ b/docs/data/material/components/snackbars/AutohideSnackbar.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import Button from '@mui/material/Button'; -import Snackbar from '@mui/material/Snackbar'; +import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar'; export default function AutohideSnackbar() { const [open, setOpen] = React.useState(false); @@ -9,7 +9,10 @@ export default function AutohideSnackbar() { setOpen(true); }; - const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => { + const handleClose = ( + event: React.SyntheticEvent | Event, + reason?: SnackbarCloseReason, + ) => { if (reason === 'clickaway') { return; } diff --git a/docs/data/material/components/snackbars/ConsecutiveSnackbars.tsx b/docs/data/material/components/snackbars/ConsecutiveSnackbars.tsx index 803b3f2f98d6e3..633379ab04a5c4 100644 --- a/docs/data/material/components/snackbars/ConsecutiveSnackbars.tsx +++ b/docs/data/material/components/snackbars/ConsecutiveSnackbars.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import Button from '@mui/material/Button'; -import Snackbar from '@mui/material/Snackbar'; +import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar'; import IconButton from '@mui/material/IconButton'; import CloseIcon from '@mui/icons-material/Close'; @@ -32,7 +32,10 @@ export default function ConsecutiveSnackbars() { setSnackPack((prev) => [...prev, { message, key: new Date().getTime() }]); }; - const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => { + const handleClose = ( + event: React.SyntheticEvent | Event, + reason?: SnackbarCloseReason, + ) => { if (reason === 'clickaway') { return; } diff --git a/docs/data/material/components/snackbars/CustomizedSnackbars.tsx b/docs/data/material/components/snackbars/CustomizedSnackbars.tsx index 845499080d06a0..912af5eae4927d 100644 --- a/docs/data/material/components/snackbars/CustomizedSnackbars.tsx +++ b/docs/data/material/components/snackbars/CustomizedSnackbars.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import Button from '@mui/material/Button'; -import Snackbar from '@mui/material/Snackbar'; +import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar'; import Alert from '@mui/material/Alert'; export default function CustomizedSnackbars() { @@ -10,7 +10,10 @@ export default function CustomizedSnackbars() { setOpen(true); }; - const handleClose = (event?: React.SyntheticEvent | Event, reason?: string) => { + const handleClose = ( + event?: React.SyntheticEvent | Event, + reason?: SnackbarCloseReason, + ) => { if (reason === 'clickaway') { return; } diff --git a/docs/data/material/components/snackbars/SimpleSnackbar.tsx b/docs/data/material/components/snackbars/SimpleSnackbar.tsx index 410819edb86eec..bf0aed8afdd95b 100644 --- a/docs/data/material/components/snackbars/SimpleSnackbar.tsx +++ b/docs/data/material/components/snackbars/SimpleSnackbar.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import Button from '@mui/material/Button'; -import Snackbar from '@mui/material/Snackbar'; +import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar'; import IconButton from '@mui/material/IconButton'; import CloseIcon from '@mui/icons-material/Close'; @@ -11,7 +11,10 @@ export default function SimpleSnackbar() { setOpen(true); }; - const handleClose = (event: React.SyntheticEvent | Event, reason?: string) => { + const handleClose = ( + event: React.SyntheticEvent | Event, + reason?: SnackbarCloseReason, + ) => { if (reason === 'clickaway') { return; }