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

Stop propagation on the Popover Button #1263

Merged
merged 3 commits into from
Mar 21, 2022

Conversation

RobinMalfait
Copy link
Member

This PR will stop the propagation of click events on the Popover Button that is not inside the Popover Panel. We usually have this behaviour for keyboard events and clicks but probably missed this one.

Fixes: #1260

This is only done on buttons that are **not** inside the Popover Panel.
@vercel
Copy link

vercel bot commented Mar 21, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

headlessui-vue – ./packages/playground-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/25RjQ8VkwoMJ3KDHECswZmSD6pWC
✅ Preview: https://headlessui-vue-git-stop-popover-button-propagation-tailwindlabs.vercel.app

headlessui-react – ./packages/playground-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/9Hy7aBX2L6E5kc9z899swhx7TYpb
✅ Preview: https://headlessui-react-git-stop-popover-button-pr-d0a37e-tailwindlabs.vercel.app

Comment on lines +464 to +465
event.preventDefault()
event.stopPropagation()

Choose a reason for hiding this comment

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

This change totally borks us from utilizing events.
A <Popover.Button as="div"> wrapping an element now blocks any event bubbling and we cannot actually react to these events for an item wrapped in a tooltip popover.

This is a clear inversion of control problem. I do not believe that the decision to preventDefault and stopPropagation on an event is the sole responsibility of headlessui to decide.

A user could supply an onClick function that calls preventDefault or stopPropagation if they so choose to. But with this code change the end users no longer have a choice in this.

We were forced to roll back to 1.5.0

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

Successfully merging this pull request may close these issues.

🤯 Popover.Button can not stop propagation
2 participants