-
Notifications
You must be signed in to change notification settings - Fork 82
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: restore old logic for getting focusable elements #3413
Conversation
This change causes tests to fail. I will investigate further how to handle this properly. |
ce23a34
to
6b4ad03
Compare
Kudos, SonarCloud Quality Gate passed!
|
@@ -137,6 +134,7 @@ export class FocusTrapController { | |||
* @private | |||
*/ | |||
get __focusedElementIndex() { | |||
return this.__focusableElements.findIndex(isElementFocused); | |||
const focusableElements = this.__focusableElements; | |||
return focusableElements.indexOf(focusableElements.filter(isElementFocused).pop()); |
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 check makes it work for vaadin-details
and vaadin-accordion-panel
: in those cases both host element and its focusElement
satisfy the isElementFocused
condition, so we should pick the right one.
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 is the old logic from 22.0
branch where it was previously placed:
web-components/packages/vaadin-overlay/src/vaadin-overlay.js
Lines 941 to 944 in d0f0627
_focusedIndex(elements) { | |
elements = elements || this._getFocusableElements(); | |
return elements.indexOf(elements.filter(this._isFocused).pop()); | |
} |
This ticket/PR has been released with platform 23.0.0.beta2 and is also targeting the upcoming stable 23.0.0 version. |
I have an edge case here.. not sure if it's worth to be reported I have the following structure: dialog > accordion > accordion panel > content In the content I've a list of buttons that, once clicked, remove itself and add a h3 with tabindex=-1, text and a back button to show the list of buttons again. Of course, to manage focus, I'm focusing the h3 for a11y compliance. Now the focus sits on the h3 with tabindex=-1 - I expect that the next tab focuses the back button.. but instead it vanishes and I need like 3 tabs to reach the back button. This can be worked around by using tabindex=0 on the header. So I'm not sure if you even wanna do anything 😅 |
Sounds like an edge case indeed. It's hard to say if we can make it work as expected without taking a closer look. |
Created #4863 for it - really minor, I have a workarond :) Not sure if it has other implications, that I can't forsee tho. |
Description
vaadin-accordion
insidevaadin-dialog
to ensure Tab worksFixes #3410
Type of change