Skip to content

Commit 63b0635

Browse files
committed
escape to close modals
1 parent 16e3a8a commit 63b0635

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/pages/Correlation/components/SavedCorrelationsModal.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ const SavedCorrelationsModal = () => {
2323
}, []);
2424

2525
const hasNoSavedFilters = _.isEmpty(correlations) || _.isNil(correlations) || fetchCorrelationsError;
26+
useEffect(() => {
27+
const handleKeyPress = (event: { key: string }) => {
28+
if (event.key === 'Escape') {
29+
closeModal();
30+
}
31+
};
32+
33+
window.addEventListener('keydown', handleKeyPress);
34+
35+
return () => {
36+
window.removeEventListener('keydown', handleKeyPress);
37+
};
38+
}, []);
2639

2740
return (
2841
<Modal

src/pages/Stream/components/Querier/SavedFiltersModal.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,20 @@ const SavedFiltersModal = () => {
244244
closeModal();
245245
}, []);
246246

247+
useEffect(() => {
248+
const handleKeyPress = (event: { key: string }) => {
249+
if (event.key === 'Escape') {
250+
closeModal();
251+
}
252+
};
253+
254+
window.addEventListener('keydown', handleKeyPress);
255+
256+
return () => {
257+
window.removeEventListener('keydown', handleKeyPress);
258+
};
259+
}, []);
260+
247261
return (
248262
<Modal
249263
opened={isSavedFiltersModalOpen}

0 commit comments

Comments
 (0)