1- import { attr , FASTElement , nullableNumberConverter , observable } from '@microsoft/fast-element' ;
1+ import { attr , FASTElement , observable } from '@microsoft/fast-element' ;
22import { keyEnter , keySpace } from '@microsoft/fast-web-utilities' ;
3- import { ButtonFormTarget , ButtonType } from './button.options.js' ;
3+ import { type ButtonFormTarget , ButtonType } from './button.options.js' ;
44
55/**
66 * A Button Custom HTML Element.
@@ -42,7 +42,19 @@ export class BaseButton extends FASTElement {
4242 * HTML Attribute: `disabled`
4343 */
4444 @attr ( { mode : 'boolean' } )
45- disabled ?: boolean ;
45+ disabled = false ;
46+
47+ protected disabledChanged ( ) {
48+ if ( this . disabled ) {
49+ this . removeAttribute ( 'tabindex' ) ;
50+ } else {
51+ // If author sets tabindex to a non-positive value, the component should
52+ // respect it, otherwise set it to 0 to avoid the anti-pattern of setting
53+ // tabindex to a positive number. See details:
54+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex
55+ this . tabIndex = Number ( this . getAttribute ( 'tabindex' ) ?? 0 ) < 0 ? - 1 : 0 ;
56+ }
57+ }
4658
4759 /**
4860 * Indicates that the button is focusable while disabled.
@@ -54,16 +66,6 @@ export class BaseButton extends FASTElement {
5466 @attr ( { attribute : 'disabled-focusable' , mode : 'boolean' } )
5567 public disabledFocusable : boolean = false ;
5668
57- /**
58- * Sets that the button tabindex attribute
59- *
60- * @public
61- * @remarks
62- * HTML Attribute: `tabindex`
63- */
64- @attr ( { attribute : 'tabindex' , mode : 'fromView' , converter : nullableNumberConverter } )
65- public override tabIndex : number = 0 ;
66-
6769 /**
6870 * Sets the element's internal disabled state when the element is focusable while disabled.
6971 *
0 commit comments