-
Notifications
You must be signed in to change notification settings - Fork 85
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
refactor: default tabindex property to undefined in TabIndexMixin #3627
refactor: default tabindex property to undefined in TabIndexMixin #3627
Conversation
* @protected | ||
*/ | ||
tabindex: { | ||
type: Number, | ||
value: 0, |
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.
note: It would be better to have it null
by default to entirely avoid undefined
. However, that might be a breaking change for some components, so I decided not to change this behavior 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.
Overall looks good. Let's update JSDoc annotation for the mixin as it still says:
By default, the attribute is set to 0 that makes the element focusable.
@web-padawan Thanks, updated. |
* @protected | ||
* @override | ||
*/ | ||
_lastTabIndex: { |
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.
note: It turned out that DelegateFocusMixin
requires _lastTabIndex
to be 0
by default even though the tabindex
attribute is undefined
by default.
If I remove it, the tests start failing. Seems that the __forwardTabIndex
method is tied on the 0
value. It looks suspicious and it might be that a bug is hiding here, but I decided not to consider it in the scope of this refactoring.
undefined
in TabIndexMixin
undefined
in TabIndexMixintabindex
property to undefined
in TabIndexMixin
ee345e6
to
0e1e9b7
Compare
tabindex
property to undefined
in TabIndexMixinsuper._disabledChanged(disabled, oldDisabled); | ||
|
||
if (oldDisabled) { | ||
this.removeAttribute('tabindex'); |
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.
note: The tabindex
attribute is now removed by TabIndexMixin
, which has become possible as a result of making _lastTabIndex
default to undefined
.
* @protected | ||
*/ | ||
tabindex: { | ||
value: 0 |
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.
I think this will affect the vaadin-select
refactoring, which introduces a button mixin: https://github.com/vaadin/web-components/pull/3612/files#diff-936c1ce6ea70b0b86633d2f358c5c3cfa916ecfe6ad5376b5244ddbb04002315R18
If we want to apply tabindex=0
to the vaadin-select-value-button
as well (which we do currently), we have to move this to the new button mixin. It looks like the snapshot tests for select should cover this, but just wanted to mention it regardless.
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.
It is a good reminder, thanks!
1900480
to
c97ceae
Compare
bfa0059
to
485bba1
Compare
This reverts commit aab5175.
485bba1
to
0addf5b
Compare
Kudos, SonarCloud Quality Gate passed!
|
) (#3641) Co-authored-by: Sergey Vinogradov <[email protected]>
) (#3640) Co-authored-by: Sergey Vinogradov <[email protected]>
This ticket/PR has been released with Vaadin 23.1.0.alpha2 and is also targeting the upcoming stable 23.1.0 version. |
Description
The PR refactors
TabIndexMixin
so that itstabindex
property defaults toundefined
rather than0
which achieves fewer overrides in the components. There are only two cases at this moment whentabindex
needs to be initialized as0
: it isvaadin-button
and the legacyShadowFocusMixin
.Type of change
Checklist