Skip to content

Commit

Permalink
fix: Handle empty stack ref in useAssistiveHideSiblings (#2920)
Browse files Browse the repository at this point in the history
Fixes a rare issue when the popup model's stack ref is `undefined`. This will mostly happen in `StrictMode`.

[category:Components]
  • Loading branch information
NicholasBoll authored Sep 16, 2024
1 parent 59c7bda commit 9c53b31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/react/popup/lib/hooks/useAssistiveHideSiblings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useAssistiveHideSiblings = createElemPropsHook(usePopupModel)(model
}

const siblings = [
...((model.state.stackRef.current?.parentElement?.children as any) as HTMLElement[]),
...((model.state.stackRef.current?.parentElement?.children || []) as HTMLElement[]),
].filter(el => el !== model.state.stackRef.current);
const prevAriaHidden = siblings.map(el => el.getAttribute('aria-hidden'));
siblings.forEach(el => {
Expand Down

0 comments on commit 9c53b31

Please sign in to comment.