@reykjavik/hanna-react 0.10.168 → 0.10.169

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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.169
8
+
9
+ _2026-02-24_
10
+
11
+ - `Modal`:
12
+ - fix: Togling `open` prop works unreliably in modern React versions
13
+ - `Multiselect`:
14
+ - fix: Stop `'Escape'` key events bubbling and causing side-effects (e.g.
15
+ closing a parent `Modal`)
16
+
7
17
  ## 0.10.168
8
18
 
9
19
  _2026-02-23_
package/Multiselect.js CHANGED
@@ -152,6 +152,7 @@ const Multiselect = (props) => {
152
152
  }
153
153
  else if (e.key === 'Escape') {
154
154
  e.preventDefault();
155
+ e.stopPropagation();
155
156
  inputElm.blur();
156
157
  inputElm.focus();
157
158
  toggleOpen(false);
@@ -82,17 +82,6 @@ const AbstractModal = (props) => {
82
82
  }, closeDelay);
83
83
  }
84
84
  };
85
- // ---
86
- // Update open state when props.open changes. Icky but simple.
87
- const lastPropsOpen = (0, react_1.useRef)(openProp);
88
- if (openProp !== lastPropsOpen.current && openProp !== open) {
89
- lastPropsOpen.current = openProp;
90
- // these update state during render, which aborts the current render
91
- // and triggers an immediate rerender.
92
- openProp ? openModal() : closeModal();
93
- }
94
- lastPropsOpen.current = openProp;
95
- // ---
96
85
  const closeOnCurtainClick = isFickle &&
97
86
  ((e) => {
98
87
  if (e.target === e.currentTarget) {
@@ -118,6 +107,13 @@ const AbstractModal = (props) => {
118
107
  return () => removeFromModalStack(privateDomId);
119
108
  }, [] // eslint-disable-line react-hooks/exhaustive-deps
120
109
  );
110
+ (0, react_1.useEffect)(() => {
111
+ if (openProp === open) {
112
+ return;
113
+ }
114
+ openProp ? openModal() : closeModal();
115
+ }, [openProp] // eslint-disable-line react-hooks/exhaustive-deps
116
+ );
121
117
  const PortalOrFragment = props.portal !== false ? _Portal_js_1.Portal : react_1.Fragment;
122
118
  const closeButtonLabel = txt.closeButtonLabel || txt.closeButton;
123
119
  const { onClick, className } = wrapperProps;
@@ -148,6 +148,7 @@ export const Multiselect = (props) => {
148
148
  }
149
149
  else if (e.key === 'Escape') {
150
150
  e.preventDefault();
151
+ e.stopPropagation();
151
152
  inputElm.blur();
152
153
  inputElm.focus();
153
154
  toggleOpen(false);
@@ -78,17 +78,6 @@ export const AbstractModal = (props) => {
78
78
  }, closeDelay);
79
79
  }
80
80
  };
81
- // ---
82
- // Update open state when props.open changes. Icky but simple.
83
- const lastPropsOpen = useRef(openProp);
84
- if (openProp !== lastPropsOpen.current && openProp !== open) {
85
- lastPropsOpen.current = openProp;
86
- // these update state during render, which aborts the current render
87
- // and triggers an immediate rerender.
88
- openProp ? openModal() : closeModal();
89
- }
90
- lastPropsOpen.current = openProp;
91
- // ---
92
81
  const closeOnCurtainClick = isFickle &&
93
82
  ((e) => {
94
83
  if (e.target === e.currentTarget) {
@@ -114,6 +103,13 @@ export const AbstractModal = (props) => {
114
103
  return () => removeFromModalStack(privateDomId);
115
104
  }, [] // eslint-disable-line react-hooks/exhaustive-deps
116
105
  );
106
+ useEffect(() => {
107
+ if (openProp === open) {
108
+ return;
109
+ }
110
+ openProp ? openModal() : closeModal();
111
+ }, [openProp] // eslint-disable-line react-hooks/exhaustive-deps
112
+ );
117
113
  const PortalOrFragment = props.portal !== false ? Portal : Fragment;
118
114
  const closeButtonLabel = txt.closeButtonLabel || txt.closeButton;
119
115
  const { onClick, className } = wrapperProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.168",
3
+ "version": "0.10.169",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",