Skip to content

Commit

Permalink
fix: Handle empty stack ref in useAssistiveHideSiblings
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`.
  • Loading branch information
NicholasBoll authored Sep 13, 2024
1 parent 59c7bda commit 2ad50d8
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 2ad50d8

Please sign in to comment.