@reykjavik/hanna-react 0.10.110 → 0.10.112

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,7 +4,13 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
- ## 0.10.110
7
+ ## 0.10.112
8
+
9
+ _2023-11-17_
10
+
11
+ - fix: `Modal` not reoppening when `open` prop is toggled
12
+
13
+ ## 0.10.110 – 0.10.111
8
14
 
9
15
  _2023-11-10_
10
16
 
package/Modal.js CHANGED
@@ -7,7 +7,7 @@ const _AbstractModal_js_1 = require("./_abstract/_AbstractModal.js");
7
7
  exports.defaultModalTexts = _AbstractModal_js_1.defaultAbstractModalTexts;
8
8
  const Modal = (props) => {
9
9
  const { bling, render, children } = props;
10
- return (react_1.default.createElement(_AbstractModal_js_1.AbstractModal, Object.assign({}, props, { bem: "modal", render: (renderProps) => {
10
+ return (react_1.default.createElement(_AbstractModal_js_1.AbstractModal, Object.assign({}, props, { bem: "Modal", render: (renderProps) => {
11
11
  const _children = render ? render(renderProps) : children;
12
12
  return bling ? (react_1.default.createElement(react_1.default.Fragment, null,
13
13
  _children,
@@ -74,12 +74,17 @@ const AbstractModal = (props) => {
74
74
  setTimeout(props.onClosed, closeDelay);
75
75
  }
76
76
  };
77
+ // ---
78
+ // Update open state when props.open changes. Icky but simple.
77
79
  const lastPropsOpen = (0, react_1.useRef)(props.open);
78
- // Update state when props.open changes. Icky but simple.
79
80
  if (props.open !== lastPropsOpen.current && props.open !== open) {
80
81
  lastPropsOpen.current = props.open;
82
+ // these update state during render, which aborts the current render
83
+ // and triggers an immediate rerender.
81
84
  props.open ? openModal() : closeModal();
82
85
  }
86
+ lastPropsOpen.current = props.open;
87
+ // ---
83
88
  const closeOnCurtainClick = isFickle &&
84
89
  ((e) => {
85
90
  if (e.target === e.currentTarget) {
package/esm/Modal.js CHANGED
@@ -3,7 +3,7 @@ import { AbstractModal, defaultAbstractModalTexts, } from './_abstract/_Abstract
3
3
  export const defaultModalTexts = defaultAbstractModalTexts;
4
4
  export const Modal = (props) => {
5
5
  const { bling, render, children } = props;
6
- return (React.createElement(AbstractModal, Object.assign({}, props, { bem: "modal", render: (renderProps) => {
6
+ return (React.createElement(AbstractModal, Object.assign({}, props, { bem: "Modal", render: (renderProps) => {
7
7
  const _children = render ? render(renderProps) : children;
8
8
  return bling ? (React.createElement(React.Fragment, null,
9
9
  _children,
@@ -70,12 +70,17 @@ export const AbstractModal = (props) => {
70
70
  setTimeout(props.onClosed, closeDelay);
71
71
  }
72
72
  };
73
+ // ---
74
+ // Update open state when props.open changes. Icky but simple.
73
75
  const lastPropsOpen = useRef(props.open);
74
- // Update state when props.open changes. Icky but simple.
75
76
  if (props.open !== lastPropsOpen.current && props.open !== open) {
76
77
  lastPropsOpen.current = props.open;
78
+ // these update state during render, which aborts the current render
79
+ // and triggers an immediate rerender.
77
80
  props.open ? openModal() : closeModal();
78
81
  }
82
+ lastPropsOpen.current = props.open;
83
+ // ---
79
84
  const closeOnCurtainClick = isFickle &&
80
85
  ((e) => {
81
86
  if (e.target === e.currentTarget) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.110",
3
+ "version": "0.10.112",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",