Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(react-popover): update story to avoid Popover re-opening #33925

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs(react-popover): update story to avoid Popover re-opening
  • Loading branch information
layershifter committed Feb 28, 2025
commit 486a065ab192ff388426afbe2ce0f481b7534184
Original file line number Diff line number Diff line change
@@ -31,7 +31,19 @@ export const WithoutTrigger = () => {
<Button {...restoreFocusTargetAttribute} ref={buttonRef} onClick={() => setOpen(s => !s)}>
Toggle popover
</Button>
<Popover onOpenChange={(_, data) => setOpen(data.open)} trapFocus open={open} positioning={{ positioningRef }}>
<Popover
onOpenChange={(e, data) => {
if (e.target === buttonRef.current) {
// Ignore events that are triggered by the button to avoid re-opening the popover
return;
}

setOpen(data.open);
}}
trapFocus
open={open}
positioning={{ positioningRef }}
>
<PopoverSurface aria-labelledby={headerId}>
<div>
<h3 id={headerId} className={styles.contentHeader}>
Loading
Oops, something went wrong.