Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-web-components/Accordion 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Accordion. - Dark Mode.normal.chromium_1.png 3154 Changed
vr-tests-web-components/Avatar 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Avatar. - Dark Mode.normal.chromium_1.png 298 Changed
vr-tests-web-components/MenuList 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/MenuList. - Dark Mode.normal.chromium.png 498 Changed
vr-tests-web-components/TextInput 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/TextInput. - Dark Mode.normal.chromium_1.png 288 Changed

"type": "prerelease",
"comment": "fix: change tabindex logic for button and switch, remove automatic assignment of false for button disabled attr",
"packageName": "@fluentui/web-components",
"email": "13071055+chrisdholt@users.noreply.github.com",
"dependentChangeType": "patch"
}
26 changes: 14 additions & 12 deletions packages/web-components/src/button/button.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,23 @@ export class BaseButton extends FASTElement {
* HTML Attribute: `disabled`
*/
@attr({ mode: 'boolean' })
disabled = false;
disabled!: boolean;

protected disabledChanged() {
if (!this.$fastController.isConnected) {
return;
}
private setTabIndex(): void {
if (this.disabled) {
this.removeAttribute('tabindex');
} else {
// If author sets tabindex to a non-positive value, the component should
// respect it, otherwise set it to 0 to avoid the anti-pattern of setting
// tabindex to a positive number. See details:
// https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex
this.tabIndex = Number(this.getAttribute('tabindex') ?? 0) < 0 ? -1 : 0;
return;
}

// If author sets tabindex to a non-positive value, the component should
// respect it, otherwise set it to 0 to avoid the anti-pattern of setting
// tabindex to a positive number. See details:
// https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex
this.tabIndex = Number(this.getAttribute('tabindex') ?? 0) < 0 ? -1 : 0;
}

protected disabledChanged() {
this.setTabIndex();
}

/**
Expand Down Expand Up @@ -262,7 +264,7 @@ export class BaseButton extends FASTElement {
connectedCallback(): void {
super.connectedCallback();
this.elementInternals.ariaDisabled = `${!!this.disabledFocusable}`;
this.disabledChanged();
this.setTabIndex();
}

constructor() {
Expand Down
24 changes: 15 additions & 9 deletions packages/web-components/src/checkbox/checkbox.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,26 @@ export class BaseCheckbox extends FASTElement {
@observable
public disabled?: boolean;

private setTabIndex(): void {
if (this.disabled) {
this.removeAttribute('tabindex');
return;
}

// If author sets tabindex to a non-positive value, the component should
// respect it, otherwise set it to 0 to avoid the anti-pattern of setting
// tabindex to a positive number. See details:
// https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex
this.tabIndex = Number(this.getAttribute('tabindex') ?? 0) < 0 ? -1 : 0;
}

/**
* Toggles the disabled state when the user changes the `disabled` property.
*
* @internal
*/
protected disabledChanged(prev: boolean | undefined, next: boolean | undefined): void {
if (this.disabled) {
this.removeAttribute('tabindex');
} else {
// If author sets tabindex to a non-positive value, the component should
// respect it, otherwise set it to 0 to avoid the anti-pattern of setting
// tabindex to a positive number. See details:
// https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex
this.tabIndex = Number(this.getAttribute('tabindex') ?? 0) < 0 ? -1 : 0;
}
this.setTabIndex();
this.elementInternals.ariaDisabled = this.disabled ? 'true' : 'false';
toggleState(this.elementInternals, 'disabled', this.disabled);
}
Expand Down Expand Up @@ -353,6 +358,7 @@ export class BaseCheckbox extends FASTElement {
super.connectedCallback();

this.disabled = !!this.disabledAttribute;
this.setTabIndex();
this.setAriaChecked();
this.setValidity();
}
Expand Down