Migrate components to eslint

This commit is contained in:
Chris Svenningsen 2020-09-11 17:46:52 -07:00 committed by Josh Perez
parent de66486e41
commit b13dbcfa77
69 changed files with 875 additions and 800 deletions

View file

@ -14,7 +14,6 @@ export type OwnProps = {
export type Props = OwnProps & ConfirmationDialogProps;
export const ConfirmationModal = React.memo(
// tslint:disable-next-line max-func-body-length
({ i18n, onClose, children, ...rest }: Props) => {
const [root, setRoot] = React.useState<HTMLElement | null>(null);
@ -54,13 +53,22 @@ export const ConfirmationModal = React.memo(
[onClose]
);
const handleKeyCancel = React.useCallback(
(e: React.KeyboardEvent) => {
if (e.target === e.currentTarget && e.keyCode === 27) {
onClose();
}
},
[onClose]
);
return root
? createPortal(
<div
// Not really a button. Just a background which can be clicked to close modal
role="button"
role="presentation"
className="module-confirmation-dialog__overlay"
onClick={handleCancel}
onKeyUp={handleKeyCancel}
>
<ConfirmationDialog i18n={i18n} {...rest} onClose={onClose}>
{children}