firefox checkbox overlap workaround (#2329)

This commit is contained in:
Patryk Andrzejewski 2022-09-28 15:14:31 +02:00 committed by GitHub
parent 575a91b5e9
commit 7dc06cef91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,11 @@ export type CheckboxProps = Omit<
error?: boolean; error?: boolean;
}; };
const firefoxHandler = (event, onChange, checked) => {
event.preventDefault();
onChange(event, checked);
};
const Checkbox: React.FC<CheckboxProps> = ({ helperText, error, ...props }) => { const Checkbox: React.FC<CheckboxProps> = ({ helperText, error, ...props }) => {
const { disableClickPropagation, ...rest } = props; const { disableClickPropagation, ...rest } = props;
const classes = useStyles(); const classes = useStyles();
@ -32,7 +37,17 @@ const Checkbox: React.FC<CheckboxProps> = ({ helperText, error, ...props }) => {
<MuiCheckbox <MuiCheckbox
{...rest} {...rest}
onClick={ onClick={
disableClickPropagation ? event => event.stopPropagation() : undefined disableClickPropagation
? event => {
event.stopPropagation();
/*
Workaround for firefox
ref: https://bugzilla.mozilla.org/show_bug.cgi?id=62151
*/
firefoxHandler(event, rest.onChange, rest.checked);
}
: undefined
} }
/> />
{helperText && ( {helperText && (