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

Add props for controlling close behavior of Dialog #3635

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

twhitbeck
Copy link

Added two new props to Dialog

  • closeOnOutsideClick, defaults to true to match current behavior but allows passing false to prevent closing the dialog when clicking outside
  • closeOnEscape, defaults to true to match current behavior but allows passing false to prevent closing the dialog when pressing the Escape key

The other option I considered was to pass an argument to onClose indicating what action is causing the close. But this would be a backwards incompatible change, since onClose is currently called with false. Possibly the reason could be the 2nd argument to onClose, so it would be onClose: (open: false, reason: "escape" | "click-outside")

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 3:55pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 3:55pm

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.

1 participant