Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Header drawer] fix header locales closing dropdown too soon and ESC behaviour #2472
[Header drawer] fix header locales closing dropdown too soon and ESC behaviour #2472
Changes from 5 commits
1b8c30f
636e99f
f439347
7c5f04e
df6fa0c
bad3342
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to fix the issue where when using the
ESC
key to close the menu drawer, it doesn't remove the overlay.The
aria-expanded
attribute is being toggle based on a click event on line17-19
. But there is nothing taking care of it for theESC
event.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naturally I went to see why the more generic handlers and onKeyUpEscape weren't also managing the esc event, and it appears to be because of the nested details/summary elements specifically involved in the header drawer using
if (summary.closest('header-drawer')) return;
I don't like that this needs to be an exception for a specific element, but since header drawer is already handling other managing other stuff on open/close, it's probably ok.Though I notice the filters drawer always closes the whole drawer on esc, even from a nested details. I'd somewhat expect if we solved the header issue more generically, it would carry over to this (and maybe future use cases) https://screenshot.click/05-40-k2cj6-im39u.mp4
That said, it's probably more important that we fix the header issues so I won't block this fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I found the source of the problem. I pushed a fix for it. I don't think it's ideal in a way as it might not be very future proof and we could maybe have a better logic. But for now it does the trick. Let me know what you think 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm imagining targeting those elements without using section-specific classes by checking if they don't have
details
parents or something, so it's completely generic, but I also don't know how feasible that is in practice, so what you have covers us for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I couldn't see where this could be used. I tried to look at where we apply focus in our JS but it didn't seem like we are actually focusing on that element at any moment 🤔
I might be missing something so let me know if you catch anything.
Basically here, when clicking on the scrollbar from the locale dropdown, it would register the click as if it was on this
menu-drawer
element and trigger thefocusout
event which closes the dropdown. Removing that tab index fixes it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting one, I tried to remove
tabindex="-1"
from children elements of this element as well and didn't notice any difference 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I don't like removing stuff I can't vouch for, but I also couldn't find the purpose for it being on this element. If anything I would expect the tabindex to be on the role="list".