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

[Popover] Don't stick upon click with openOnHover prop #819

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
22 changes: 21 additions & 1 deletion packages/react/src/Popover/Trigger/PopoverTrigger.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,29 @@ describe('<Popover.Trigger />', () => {
expect(trigger).not.to.have.attribute('data-pressed');
});

it('should not have the data-popup-open and data-pressed attributes when open by click when `openOnHover=true` and `delay=0`', async () => {
const { user } = await render(
<Popover.Root delay={0} openOnHover animated={false}>
<Popover.Trigger />
</Popover.Root>,
);

const trigger = screen.getByRole('button');

await user.hover(trigger);

// Closes instantly after opening due to `useClick` prop `stickIfOpen=false`
await act(async () => {
trigger.click();
});
Comment on lines +63 to +68
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is why it's configured by default, but it depends on the delay you use. If you happen to click <50ms after it opens coincidentally, it's pretty unexpected


expect(trigger).not.to.have.attribute('data-popup-open');
expect(trigger).not.to.have.attribute('data-pressed');
});

it('should have the data-popup-open and data-pressed attributes when open by click when `openOnHover=true`', async () => {
const { user } = await render(
<Popover.Root openOnHover delay={0} animated={false}>
<Popover.Root openOnHover animated={false}>
<Popover.Trigger />
</Popover.Root>,
);
Expand Down