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

fix(masthead): Esc to close Cloud Masthead #10555

Conversation

pjudge
Copy link
Contributor

@pjudge pjudge commented Jun 13, 2023

Related Ticket(s)

Closes #10174

Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that.

Changelog

Changed

  • Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 13, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 13, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 13, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 13, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 13, 2023

@ibmdotcom-bot
Copy link
Contributor

@pjudge pjudge marked this pull request as ready for review June 13, 2023 19:24
@pjudge pjudge requested a review from a team as a code owner June 13, 2023 19:24
Copy link
Member

@jkaeser jkaeser 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 excellent. I've confirmed the fix works in both the web component packages' deploy previews. Great work!

If you're interested, I have a couple notes that won't functionally change anything but are some opportunities to make this a smidge more idiomatic:

  1. Instead of adding an event listener in the connectedCallback(), try using the @HostListener() decorator above the _handleKeydownTrigger method. See the _handleBlur method for an example. This way we're consistent with how we're handling event listeners.
  2. Since this event listener is being set on the custom element itself, we shouldn't need to set it on the <a> tag with the @keydown expression anymore.
  3. I noticed both the BXHeaderMenu._trigger and DDSMegamenuTopNavMenu._topMenuItem properties store references to the same thing: the top-level menu item. Seems like an opportunity to reduce some redundancy. Let me know if you want to talk about this one.

@jkaeser jkaeser added package: web components Work necessary for the IBM.com Library web components package package: carbon web components 👀 eyes needed labels Jun 13, 2023
@annawen1 annawen1 changed the title 10174: Esc to close Cloud Masthead fix(masthead): Esc to close Cloud Masthead Jun 14, 2023
@pjudge
Copy link
Contributor Author

pjudge commented Jun 14, 2023

@jkaeser Thank you so much for your thorough and thoughtful review! I've made the updates you suggested and when the build finishes, it's ready for a re-review 👍

Copy link
Member

@jkaeser jkaeser left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my feedback! Just one change needs reverting and I'd say we're good to go here.

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 14, 2023

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jun 14, 2023

Copy link
Member

@annawen1 annawen1 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @pjudge and @jkaeser!

@jkaeser jkaeser added Ready to merge Label for the pull requests that are ready to merge and removed 👀 eyes needed labels Jun 15, 2023
@jkaeser
Copy link
Member

jkaeser commented Jun 15, 2023

@annawen1 Looks like Percy failed to generate some screenshots and is blocking this merge. Are you able to resolve that, or do we need to reach out to the design team?

@kennylam
Copy link
Member

Looks like Percy failed to generate some screenshots and is blocking this merge. Are you able to resolve that, or do we need to reach out to the design team?

Fixed!

@kodiakhq kodiakhq bot merged commit de67bf8 into carbon-design-system:main Jun 15, 2023
kennylam pushed a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Jun 22, 2023
### Related Ticket(s)

Closes carbon-design-system#10174 

### Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that. 

### Changelog

**Changed**

- Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.
IgnacioBecerra pushed a commit that referenced this pull request Jun 22, 2023
### Related Ticket(s)

Closes #10174 

### Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that. 

### Changelog

**Changed**

- Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.

Co-authored-by: Pauline <pauline.judge@lullabot.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kennylam pushed a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Dec 4, 2023
### Related Ticket(s)

Closes carbon-design-system#10174 

### Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that. 

### Changelog

**Changed**

- Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.
kennylam added a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Dec 4, 2023
… (carbon-design-system#10588)

### Related Ticket(s)

Closes carbon-design-system#10174 

### Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that. 

### Changelog

**Changed**

- Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.

Co-authored-by: Pauline <pauline.judge@lullabot.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kennylam pushed a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Jun 11, 2024
### Related Ticket(s)

Closes carbon-design-system#10174 

### Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that. 

### Changelog

**Changed**

- Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.
kennylam added a commit to kennylam/carbon-for-ibm-dotcom that referenced this pull request Jun 11, 2024
… (carbon-design-system#10588)

### Related Ticket(s)

Closes carbon-design-system#10174 

### Description

The Cloud masthead (and other mastheads) simple menus were not closing upon hitting Esc if focus was inside the submenu. This PR fixes that. 

### Changelog

**Changed**

- Adds ability to close Cloud Masthead non-megamenu (and all non-megamenus) with Esc key, just as megamenus already do.

Co-authored-by: Pauline <pauline.judge@lullabot.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature flag package: carbon web components package: web components Work necessary for the IBM.com Library web components package Ready to merge Label for the pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cloud-Masthead v1]: a11y Feature/improvement - support Esc key to close the Dropdown in masthead component
5 participants