react-pure-modal 2.2.6 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-pure-modal",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "React modal",
5
5
  "main": "dist/react-pure-modal.min.js",
6
6
  "types": "dist/react-pure-modal.d.ts",
@@ -67,7 +67,7 @@
67
67
  "yargs": "15.4.1"
68
68
  },
69
69
  "peerDependencies": {
70
- "react": "^15.3.0 || ^16.0 || ^17.0 || ^18.0",
71
- "react-dom": "^15.3.0 || ^16.0 || ^17.0 || ^18.0"
70
+ "react": "^15.3.0 || ^16.0 || ^17.0 || ^18.0 || ^19.0",
71
+ "react-dom": "^15.3.0 || ^16.0 || ^17.0 || ^18.0 || ^19.0"
72
72
  }
73
73
  }
@@ -78,15 +78,25 @@ function PureModal(props: Props) {
78
78
  };
79
79
  }, [isOpen]);
80
80
 
81
- const handleEsc = useCallback(event => {
82
- const allModals = document.querySelectorAll('.pure-modal');
81
+ const handleEsc = useCallback(
82
+ event => {
83
+ const allModals = document.querySelectorAll('.pure-modal');
84
+ const isManyModalsOpen = allModals.length > 1; // open modal in modal
85
+ const firstModalData = allModals[allModals.length - 1];
86
+
87
+ if (isManyModalsOpen && !firstModalData.className.includes(hash)) {
88
+ return false; // closing only current modal
89
+ }
83
90
 
84
- if (allModals.length && allModals[allModals.length - 1].classList.contains(hash)) return false;
91
+ if (event.key === 'Escape' && document.activeElement) {
92
+ close(event);
93
+ return true;
94
+ }
85
95
 
86
- if (event.key === 'Escape' && document.activeElement) {
87
- close(event);
88
- }
89
- }, []);
96
+ return false;
97
+ },
98
+ [close, hash],
99
+ );
90
100
 
91
101
  if (!isOpen) {
92
102
  return null;