Skip to content

Commit

Permalink
[docs][material-ui][Snackbar] Improve close reason type in demos (@…
Browse files Browse the repository at this point in the history
…sai6855) (#43105)

Co-authored-by: sai chand <60743144+sai6855@users.noreply.github.com>
Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
  • Loading branch information
3 people authored Jul 28, 2024
1 parent 4e38398 commit 7997eec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions docs/data/material/components/snackbars/AutohideSnackbar.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions docs/data/material/components/snackbars/SimpleSnackbar.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
}
Expand Down

0 comments on commit 7997eec

Please sign in to comment.