@snapdragonsnursery/react-components 1.18.1 → 1.18.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/AuthButtons.jsx +35 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapdragonsnursery/react-components",
3
- "version": "1.18.1",
3
+ "version": "1.18.2",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -203,23 +203,44 @@ function AuthButtons({ theme, setTheme, authState, setAuthState }) {
203
203
  // Setup Popper when menu is open
204
204
  useEffect(() => {
205
205
  if (menuOpen && buttonRef.current && menuRef.current) {
206
- popperInstance.current = createPopper(
207
- buttonRef.current,
208
- menuRef.current,
209
- {
210
- placement: "bottom-end",
211
- modifiers: [
212
- { name: "preventOverflow", options: { boundary: "viewport" } },
206
+ // Add a small delay to ensure DOM nodes are fully mounted
207
+ // This prevents MutationObserver errors when Popper tries to observe nodes
208
+ const timeoutId = setTimeout(() => {
209
+ // Double-check refs are still valid before creating Popper
210
+ if (
211
+ buttonRef.current &&
212
+ menuRef.current &&
213
+ buttonRef.current instanceof Node &&
214
+ menuRef.current instanceof Node
215
+ ) {
216
+ popperInstance.current = createPopper(
217
+ buttonRef.current,
218
+ menuRef.current,
213
219
  {
214
- name: "flip",
215
- options: {
216
- fallbackPlacements: ["bottom-start", "top-end", "top-start"],
217
- },
218
- },
219
- ],
220
+ placement: "bottom-end",
221
+ modifiers: [
222
+ { name: "preventOverflow", options: { boundary: "viewport" } },
223
+ {
224
+ name: "flip",
225
+ options: {
226
+ fallbackPlacements: ["bottom-start", "top-end", "top-start"],
227
+ },
228
+ },
229
+ ],
230
+ }
231
+ );
232
+ }
233
+ }, 0);
234
+
235
+ return () => {
236
+ clearTimeout(timeoutId);
237
+ if (popperInstance.current) {
238
+ popperInstance.current.destroy();
239
+ popperInstance.current = null;
220
240
  }
221
- );
241
+ };
222
242
  }
243
+
223
244
  return () => {
224
245
  if (popperInstance.current) {
225
246
  popperInstance.current.destroy();