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

PopoverAnchor should take precedence over PopoverDisclosure #3729

Open
bengry opened this issue Apr 23, 2024 · 3 comments · May be fixed by #3743
Open

PopoverAnchor should take precedence over PopoverDisclosure #3729

bengry opened this issue Apr 23, 2024 · 3 comments · May be fixed by #3743

Comments

@bengry
Copy link

bengry commented Apr 23, 2024

Current behavior

It seems like the <PopoverAnchor> component is not working as expected - seems like Ariakit is ignoring it completely.

Steps to reproduce the bug

  1. Open https://stackblitz.com/edit/vitejs-vite-1vpcyg?file=src%2FApp.tsx
  2. Click the "Accept Invite" button.

Expected behavior

The popover should appear next to the "Different anchor" element, NOT the "Accept Invite" button.

Workaround

Manually saving a ref to PopoverAnchor and using that in getAnchorRect:

<Ariakit.Popover getAnchorRect={() => anchorRef.current?.getBoundingClientRect() ?? null}>
  ...
</Ariakit.Popover>

Possible solutions

No response

@diegohaz
Copy link
Member

This is because PopoverDisclosure already implements PopoverAnchor underneath and it's taking precedence.

Though I agree in this case PopoverAnchor, when used together with PopoverDisclosure, should always take precedence.

@diegohaz diegohaz changed the title PopoverAnchor not working PopoverAnchor should take precedence over PopoverDisclosure Apr 23, 2024
@bengry
Copy link
Author

bengry commented Apr 23, 2024

This is because PopoverDisclosure already implements PopoverAnchor underneath and it's taking precedence.

Though I agree in this case PopoverAnchor, when used together with PopoverDisclosure, should always take precedence.

So basically (right now) if you use <PopoverAnchor> you have to connect the store to the trigger manually, or is there another way? Getting the aria attributes etc. ([aria-expanded], [aria-haspopup], etc.) is still relevant for the trigger, even if it's not related to where the popover will be placed at the time.

@diegohaz
Copy link
Member

I'd say using getAnchorRect on Popover is a better solution for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants