Skip to content

Commit

Permalink
Merge pull request #85 from VadymBezsmertnyi/master
Browse files Browse the repository at this point in the history
Fix remove class in body
  • Loading branch information
max-mykhailenko authored Jul 5, 2023
2 parents 5479c60 + cb51729 commit 51f88e5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/react-pure-modal.min.js

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

2 changes: 1 addition & 1 deletion example/example.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

8 changes: 7 additions & 1 deletion src/react-pure-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ function PureModal(props: Props) {

const { isOpen, onClose } = props;

const removeClassBody = useCallback(() => {
document.body.classList.remove('body-modal-fix');
}, []);

useEffect(() => {
if (isOpen) {
open();
} else {
close();
}
}, [isOpen]);

Expand Down Expand Up @@ -64,7 +70,7 @@ function PureModal(props: Props) {

function unsetModalContext() {
document.removeEventListener('keydown', handleEsc);
document.body.classList.remove('body-modal-fix');
removeClassBody();
setX(null);
setY(null);
setDeltaX(0);
Expand Down

0 comments on commit 51f88e5

Please sign in to comment.