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

Trigger onClose when Dialog backdrop is clicked #4613

Merged
merged 9 commits into from
Jun 11, 2024

Conversation

joshblack
Copy link
Member

Note

This is a re-open of #4565 which was reverted as part of the last release

Relates to https://github.com/github/primer/issues/2531
Relates to https://github.com/github/repos/issues/9248
Alternative to https://github.com/github/primer/issues/1838

I'd like to allow the v2 Dialog to be closed by clicking on the backdrop overlay. This is currently not supported, though the v1 Dialog and PVC dialog support this behavior.

Based on the usage guidelines, there are some unique cases where clicking the backdrop should not close the dialog. By passing in a new backdrop gesture, there is an escape hatch for these unique cases to ignore backdrop events on a case-by-case basis.

Changelog

New

Dialog and ConfirmationDialog can now be closed by clicking on the backdrop round the dialog. This will cause onClose to be called with a new 'backdrop' gesture.

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@joshblack joshblack requested a review from keithamus May 20, 2024 18:13
@joshblack joshblack requested a review from a team as a code owner May 20, 2024 18:13
Copy link

changeset-bot bot commented May 20, 2024

🦋 Changeset detected

Latest commit: 9c35602

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented May 20, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 89.46 KB (+0.02% 🔺)
packages/react/dist/browser.umd.js 89.73 KB (-0.07% 🔽)

@github-actions github-actions bot temporarily deployed to storybook-preview-4613 May 20, 2024 18:17 Inactive
@joshblack
Copy link
Member Author

wanted to bump you @keithamus when you have a sec 👀 For context, this was the PR for closing when the backdrop is clicked. You had proposed an alternate way for this but I'm not sure what that would look like. If you have a sec, or want to pair, would appreciate it a ton

@keithamus
Copy link
Member

The web platform will provide closedby=any (whatwg/html#10157) as the value for closing via a click outside the dialog, and the onclose handler isn't told how the element is closed as there's not a strong use case for being able to differentiate. AIUI the monolith doesn't use the onclose hint that Primer provides and I'm hesitant to extend it especially if it means we're unable to move to the web platform native features which often are more accessible than we could possibly provide (for example allowing for operating system gestures to close the dialog too).

Copy link

@theinterned theinterned left a comment

Choose a reason for hiding this comment

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

This looks great to me!

I can certainly see @keithamus argument for staying within the API of the web platform, and honestly I can't think of a reason I'd distinguish between a close button, esc key, and a background click. I could potentially see the need for cancel vs confirm type actions. I suspect in web platform terms the event target could be used to make these distinctions? The same could be done in the react world right?

Still it seems like the removal of "gestures" would be a breaking API change and need not hold up this PR?

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

This LGTM

@joshblack joshblack added this pull request to the merge queue Jun 11, 2024
Merged via the queue into main with commit eb2ab13 Jun 11, 2024
30 checks passed
@joshblack joshblack deleted the dg/dialog-backdrop-click branch June 11, 2024 17:52
@primer primer bot mentioned this pull request Jun 11, 2024
@@ -98,9 +98,9 @@ export interface DialogProps extends SxProp {

/**
* This method is invoked when a gesture to close the dialog is used (either
* an Escape key press or clicking the "X" in the top-right corner). The
* an Escape key press, clicking the backdrop, or clicking the "X" in the top-right corner). The
Copy link
Contributor

Choose a reason for hiding this comment

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

should this reference to clicking the backdrop be removed since that information isn't actually communicated?

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.

5 participants