Skip to content

Commit

Permalink
chore: 포커스 트랩
Browse files Browse the repository at this point in the history
  • Loading branch information
woochul2 committed May 22, 2022
1 parent e89207b commit 111bd43
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 23 deletions.
134 changes: 134 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"next-redux-wrapper": "^7.0.5",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-focus-lock": "^2.9.1",
"react-redux": "^8.0.1",
"react-textarea-autosize": "^8.3.3",
"sockjs-client": "^1.6.0",
Expand Down
46 changes: 24 additions & 22 deletions src/components/DeleteModal/DeleteModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Button from 'components/Button';
import { MouseEventHandler } from 'react';
import styles from './DeleteModal.module.scss';
import FocusLock from 'react-focus-lock';

export type DeleteModalProps = {
title: string;
Expand All @@ -10,7 +11,6 @@ export type DeleteModalProps = {
buttonName?: string;
};

// TODO: 포커스 트랩
function DeleteModal({
title,
message,
Expand All @@ -19,29 +19,31 @@ function DeleteModal({
buttonName,
}: DeleteModalProps) {
return (
<div
className={styles.container}
onClick={(event) => {
const target = event.target as HTMLElement;
if (target.classList.contains(styles.container)) {
onCancel(event);
}
}}
data-testid="delete-modal"
>
<div className={styles.main}>
<h3>{title}</h3>
<p>{message}</p>
<div className={styles.buttonsContainer}>
<Button variant="plain" onClick={onCancel} ariaLabel="삭제 취소">
취소
</Button>
<Button onClick={onConfirm} variant="error">
{buttonName || '삭제'}
</Button>
<FocusLock>
<div
className={styles.container}
onClick={(event) => {
const target = event.target as HTMLElement;
if (target.classList.contains(styles.container)) {
onCancel(event);
}
}}
data-testid="delete-modal"
>
<div className={styles.main}>
<h3>{title}</h3>
<p>{message}</p>
<div className={styles.buttonsContainer}>
<Button variant="plain" onClick={onCancel} ariaLabel="삭제 취소">
취소
</Button>
<Button onClick={onConfirm} variant="error">
{buttonName || '삭제'}
</Button>
</div>
</div>
</div>
</div>
</FocusLock>
);
}

Expand Down
Loading

0 comments on commit 111bd43

Please sign in to comment.