Skip to content

Add Dialog::Header close_scheme, close_label params #3373

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

Closed
wants to merge 2 commits into from

Conversation

myabc
Copy link
Contributor

@myabc myabc commented Mar 10, 2025

What are you trying to accomplish?

Currently it is not possible to specify a custom ARIA label for the Dialog close button. This is problematic for apps (like OpenProject) with fully localized UIs.

This PR adds two new params to Primer::Alpha::Dialog::Header#initialize:

  • @param close_scheme [Symbol] Whether the component can be closed with an "x" button. Either :close or :none.
  • @param close_label [String] The aria-label text of the close "x" button.

This allows for a few new scenarios:

  • localization: the caller can pass a localized string as close_label: argument (e.g. with I18n.t).
  • completely hiding the close button: this may be desirable from a UX perspective if the caller renders a close button elsewhere in the dialog (e.g. the footer).

Screenshots

custom close label:

Screenshot 2025-03-10 at 08 03 24

without a header close button:

Screenshot 2025-03-10 at 08 03 31

the initial focussed element is the footer close button.

Integration

This should not be a breaking change.

List the issues that this change affects.

Closes # (type the GitHub issue number after #)

Related OpenProject Work Package: https://community.openproject.org/wp/61631

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

This API is modelled on the Primer::Alpha::Banner component, which accepts dismiss_scheme and dismiss_label arguments.

My initial approach was to create a close_button slot - I went ahead and pushed that work (see #3374) but wasn't happy with the API. For example, in order the hide the close button, you would need to call with_close_button without a block.

Anything you want to highlight for special attention from reviewers?

Accessibility

  • Fixes axe scan violation - This change fixes an existing axe scan violation.
  • No new axe scan violation - This change does not introduce any new axe scan violations.
  • New axe violation - This change introduces a new axe scan violation. Please describe why the violation cannot be resolved below.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

Copy link

changeset-bot bot commented Mar 10, 2025

⚠️ No Changeset found

Latest commit: e6cf575

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@myabc
Copy link
Contributor Author

myabc commented Mar 10, 2025

Leaving this in draft - @HDinger, could you have a look?

@myabc myabc force-pushed the feature/dialog-header-close-params branch from ce0f31e to 10e6096 Compare March 10, 2025 13:17
myabc added 2 commits March 20, 2025 09:16
Allows the customization of the close button - or removal entirely.
@myabc myabc force-pushed the feature/dialog-header-close-params branch from 10e6096 to e6cf575 Compare March 20, 2025 13:16
Copy link
Contributor

@HDinger HDinger left a comment

Choose a reason for hiding this comment

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

As discussed, I'd vote for splitting this PR into two: One for changing the label which is pretty straightforward imho. The other one for making the close button optional which is probably more controversial.

@@ -16,6 +16,14 @@ class Header < Primer::Component
}.freeze
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys

DEFAULT_CLOSE_SCHEME = :close
CLOSE_SCHEMES = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Schemes are usually something like :danger, :primary and so on.. Since you want to achieve a boolean flag to hide and show the close button, it maybe makes sense to make that a boolean like show_close_button.

Copy link
Contributor

Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days.

@github-actions github-actions bot added the Stale Automatically marked as stale. label May 23, 2025
@github-actions github-actions bot closed this May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Automatically marked as stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants