Prevent mui card ripple on child element click

This commit is contained in:
schroda
2025-03-29 03:12:36 +01:00
parent 517610ac6d
commit 9ad1af4846
9 changed files with 53 additions and 24 deletions

View File

@@ -12,6 +12,7 @@ import PlayArrowIcon from '@mui/icons-material/PlayArrow';
import { Link } from 'react-router-dom';
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
import { ChapterReadInfo, Chapters, ChapterSourceOrderInfo } from '@/modules/chapter/services/Chapters.ts';
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
export const ContinueReadingButton = ({
showContinueReadingButton,
@@ -34,6 +35,7 @@ export const ContinueReadingButton = ({
return (
<CustomTooltip title={t(isFirstChapter ? 'global.button.start' : 'global.button.resume')}>
<Button
{...MUIUtil.preventRippleProp()}
variant="contained"
size="small"
sx={{ minWidth: 'unset', py: 0.5, px: 0.75 }}
@@ -41,7 +43,6 @@ export const ContinueReadingButton = ({
to={`${mangaLinkTo}/chapter/${chapter.sourceOrder}`}
state={Chapters.getReaderOpenChapterLocationState(chapter)}
onClick={(e) => e.stopPropagation()}
onMouseDown={(e) => e.stopPropagation()}
>
<PlayArrowIcon />
</Button>

View File

@@ -13,6 +13,7 @@ import Typography from '@mui/material/Typography';
import { MangaCardMode } from '@/modules/manga/Manga.types.ts';
import { MediaQuery } from '@/modules/core/utils/MediaQuery.tsx';
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
const BadgeContainer = styled('div')(({ theme }) => ({
display: 'flex',
@@ -57,7 +58,7 @@ export const MangaBadges = ({
component="div"
variant="contained"
size="small"
onMouseDown={(e) => e.stopPropagation()}
{...MUIUtil.preventRippleProp()}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();

View File

@@ -7,7 +7,7 @@
*/
import { useTranslation } from 'react-i18next';
import { BaseSyntheticEvent, MouseEvent, TouchEvent, ChangeEvent, useMemo, forwardRef, ForwardedRef } from 'react';
import { BaseSyntheticEvent, ChangeEvent, useMemo, forwardRef, ForwardedRef } from 'react';
import Button from '@mui/material/Button';
import Checkbox from '@mui/material/Checkbox';
import IconButton from '@mui/material/IconButton';
@@ -17,6 +17,7 @@ import { bindTrigger } from 'material-ui-popup-state';
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
import { SelectableCollectionReturnType } from '@/modules/collection/hooks/useSelectableCollection.ts';
import { MangaType } from '@/lib/graphql/generated/graphql.ts';
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
export const MangaOptionButton = forwardRef(
(
@@ -49,12 +50,6 @@ export const MangaOptionButton = forwardRef(
handleSelection?.(id, isSelected);
};
const handleClick = (e: MouseEvent | TouchEvent) => {
preventDefaultAction(e);
popupState.open(e);
bindTriggerProps.onClick(e as any);
};
if (!handleSelection) {
return null;
}
@@ -67,7 +62,7 @@ export const MangaOptionButton = forwardRef(
return (
<CustomTooltip title={t(selected ? 'global.button.deselect' : 'global.button.select')}>
<Checkbox checked={selected} onMouseDown={preventDefaultAction} onChange={handleSelectionChange} />
<Checkbox {...MUIUtil.preventRippleProp()} checked={selected} onChange={handleSelectionChange} />
</CustomTooltip>
);
}
@@ -77,10 +72,8 @@ export const MangaOptionButton = forwardRef(
<CustomTooltip title={t('global.button.options')}>
<IconButton
ref={ref}
{...bindTriggerProps}
onClick={handleClick}
{...MUIUtil.preventRippleProp(bindTriggerProps, { onClick: preventDefaultAction })}
aria-label="more"
onMouseDown={preventDefaultAction}
>
<MoreVertIcon />
</IconButton>
@@ -92,8 +85,7 @@ export const MangaOptionButton = forwardRef(
<CustomTooltip title={t('global.button.options')}>
<Button
ref={ref}
{...bindTriggerProps}
onClick={handleClick}
{...MUIUtil.preventRippleProp(bindTriggerProps, { onClick: preventDefaultAction })}
className="manga-option-button"
size="small"
variant="contained"
@@ -107,7 +99,6 @@ export const MangaOptionButton = forwardRef(
display: 'none',
},
}}
onMouseDown={(e) => e.stopPropagation()}
>
<MoreVertIcon />
</Button>