Skip to content

Commit

Permalink
[#1003][3.0] Window > ESC 기능 버그 수정
Browse files Browse the repository at this point in the history
################
- 간헐적으로 removeEventListener가 되지 않아 keydown 이벤트리스너가 중복 등록되는 문제 발생하여 관련 코드 제거
  • Loading branch information
sej-dev committed Jan 4, 2022
1 parent c19006d commit 5ffe966
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/components/window/uses.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,7 @@ const activeWindows = (() => {
return windows.length <= 0;
},
isFirstWindowOpen() {
return windows.length === 1;
},
isLastWindowClose() {
return windows.length === 0;
return sequence === 1;
},
};
})();
Expand Down Expand Up @@ -682,28 +679,17 @@ const useEscKeydownEvent = ({ closeWin, windowRef }) => {
topActiveWindow.closeWin();
};

const addKeydownEvtHandler = () => {
if (activeWindows.isFirstWindowOpen()) {
document.addEventListener('keydown', keydownEsc);
}
};

const removeKeydownEvtHandler = () => {
if (activeWindows.isLastWindowClose()) {
document.removeEventListener('keydown', keydownEsc);
}
};

const setWindowActive = () => {
isActiveStatus = true;
addActiveWindow();
addKeydownEvtHandler();
if (activeWindows.isFirstWindowOpen()) {
document.addEventListener('keydown', keydownEsc);
}
};

const setWindowInactive = () => {
const inactiveWindow = activeWindows.getWindowBySequence(sequence);
removeInactiveWindow(inactiveWindow);
removeKeydownEvtHandler();
isActiveStatus = false;
};

Expand Down

0 comments on commit 5ffe966

Please sign in to comment.