Skip to content

Commit

Permalink
refactor: do not override tabindex property to set default value (#8418)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Dec 31, 2024
1 parent b239d40 commit 2b22d9c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 38 deletions.
19 changes: 5 additions & 14 deletions packages/button/src/vaadin-button-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@ import { TabindexMixin } from '@vaadin/a11y-base/src/tabindex-mixin.js';
*/
export const ButtonMixin = (superClass) =>
class ButtonMixinClass extends ActiveMixin(TabindexMixin(FocusMixin(superClass))) {
static get properties() {
return {
/**
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
*
* @override
* @protected
*/
tabindex: {
type: Number,
value: 0,
reflectToAttribute: true,
},
};
constructor() {
super();

// Set tabindex to 0 by default
this.tabindex = 0;
}

/**
Expand Down
16 changes: 4 additions & 12 deletions packages/checkbox/src/vaadin-checkbox-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ export const CheckboxMixin = (superclass) =>
value: false,
reflectToAttribute: true,
},

/**
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
*
* @override
* @protected
*/
tabindex: {
type: Number,
value: 0,
reflectToAttribute: true,
},
};
}

Expand Down Expand Up @@ -99,6 +87,10 @@ export const CheckboxMixin = (superclass) =>
// Set the string "on" as the default value for the checkbox following the HTML specification:
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
this.value = 'on';

// Set tabindex to 0 by default to not lose focus on click in Safari
// See https://github.com/vaadin/web-components/pull/6780
this.tabindex = 0;
}

/** @protected */
Expand Down
16 changes: 4 additions & 12 deletions packages/radio-group/src/vaadin-radio-button-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ export const RadioButtonMixin = (superclass) =>
type: String,
value: '',
},

/**
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
*
* @override
* @protected
*/
tabindex: {
type: Number,
value: 0,
reflectToAttribute: true,
},
};
}

Expand All @@ -60,6 +48,10 @@ export const RadioButtonMixin = (superclass) =>
// Set the string "on" as the default value for the radio button following the HTML specification:
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
this.value = 'on';

// Set tabindex to 0 by default to not lose focus on click in Safari
// See https://github.com/vaadin/web-components/pull/6780
this.tabindex = 0;
}

/** @protected */
Expand Down

0 comments on commit 2b22d9c

Please sign in to comment.