@reykjavik/hanna-react 0.10.126 → 0.10.127

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,12 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.127
8
+
9
+ _2024-06-27_
10
+
11
+ - fix: Ref error when `MainMenu2` unmounts
12
+
7
13
  ## 0.10.126
8
14
 
9
15
  _2024-06-05_
package/MainMenu2.js CHANGED
@@ -126,12 +126,14 @@ const MainMenu2 = (props) => {
126
126
  document.addEventListener('keydown', escHandler);
127
127
  };
128
128
  const closeMenu = () => {
129
+ var _a;
129
130
  htmlCl.remove(globalClasses.menuIsOpen);
130
131
  htmlCl.add(globalClasses.menuIsClosed);
131
132
  setIsMenuOpen(false);
132
133
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
133
134
  setActiveSubmenu(defaultActive);
134
- wrapperRef.current.scrollTo(0, 0);
135
+ // closeMenu is called on umount, and then the ref might be null
136
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
135
137
  document.removeEventListener('keydown', escHandler);
136
138
  };
137
139
  (0, react_1.useEffect)(() => {
@@ -140,8 +142,8 @@ const MainMenu2 = (props) => {
140
142
  }
141
143
  htmlCl.add(globalClasses.menuIsClosed);
142
144
  return () => {
143
- closeMenu();
144
145
  htmlCl.remove(globalClasses.menuIsClosed);
146
+ closeMenu();
145
147
  };
146
148
  // eslint-disable-next-line react-hooks/exhaustive-deps
147
149
  }, [isBrowser]);
package/esm/MainMenu2.js CHANGED
@@ -122,12 +122,14 @@ export const MainMenu2 = (props) => {
122
122
  document.addEventListener('keydown', escHandler);
123
123
  };
124
124
  const closeMenu = () => {
125
+ var _a;
125
126
  htmlCl.remove(globalClasses.menuIsOpen);
126
127
  htmlCl.add(globalClasses.menuIsClosed);
127
128
  setIsMenuOpen(false);
128
129
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
129
130
  setActiveSubmenu(defaultActive);
130
- wrapperRef.current.scrollTo(0, 0);
131
+ // closeMenu is called on umount, and then the ref might be null
132
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
131
133
  document.removeEventListener('keydown', escHandler);
132
134
  };
133
135
  useEffect(() => {
@@ -136,8 +138,8 @@ export const MainMenu2 = (props) => {
136
138
  }
137
139
  htmlCl.add(globalClasses.menuIsClosed);
138
140
  return () => {
139
- closeMenu();
140
141
  htmlCl.remove(globalClasses.menuIsClosed);
142
+ closeMenu();
141
143
  };
142
144
  // eslint-disable-next-line react-hooks/exhaustive-deps
143
145
  }, [isBrowser]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.126",
3
+ "version": "0.10.127",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",