Remove unused space at bottom of snackbar without description
Get rid of unnecessary white space when there is no description to show
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CustomContentProps, SnackbarContent, VariantType } from 'notistack';
|
import { CustomContentProps, SnackbarContent, VariantType } from 'notistack';
|
||||||
import { ForwardedRef, forwardRef, memo } from 'react';
|
import { ForwardedRef, forwardRef, Fragment, memo } from 'react';
|
||||||
import Alert from '@mui/material/Alert';
|
import Alert from '@mui/material/Alert';
|
||||||
import AlertTitle from '@mui/material/AlertTitle';
|
import AlertTitle from '@mui/material/AlertTitle';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
@@ -51,11 +51,13 @@ export const SnackbarWithDescription = memo(
|
|||||||
? description?.slice(0, MAX_DESCRIPTION_LENGTH)
|
? description?.slice(0, MAX_DESCRIPTION_LENGTH)
|
||||||
: description;
|
: description;
|
||||||
|
|
||||||
|
const TitleComponent = actualDescription?.length ? AlertTitle : Fragment;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SnackbarContent ref={ref}>
|
<SnackbarContent ref={ref}>
|
||||||
<Alert severity={severity} action={finalAction}>
|
<Alert severity={severity} action={finalAction}>
|
||||||
<AlertTitle>{message}</AlertTitle>
|
<TitleComponent>{message}</TitleComponent>
|
||||||
{actualDescription}{' '}
|
{actualDescription}
|
||||||
{isDescriptionTooLong ? (
|
{isDescriptionTooLong ? (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user