From 158ba40297afef7d6b316b81bde5597a1807c4b0 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Thu, 19 Sep 2024 10:19:08 +0200 Subject: [PATCH 1/4] fix: introduce disabledInteractive property and revert focusing disabled actions in general --- .../button-link.snapshot.spec.snap.js | 1 + .../button.snapshot.spec.snap.js | 1 - src/elements/button/button/button.ts | 4 +- src/elements/button/button/readme.md | 34 ++--- .../button/common/button-common-stories.ts | 11 ++ .../button/mini-button/mini-button.ts | 6 +- src/elements/button/mini-button/readme.md | 32 ++--- ...econdary-button-link.snapshot.spec.snap.js | 1 + .../secondary-button.snapshot.spec.snap.js | 1 - .../button/secondary-button/readme.md | 34 ++--- .../secondary-button/secondary-button.ts | 4 +- ...tertiary-button-link.snapshot.spec.snap.js | 1 + .../tertiary-button.snapshot.spec.snap.js | 1 - src/elements/button/tertiary-button/readme.md | 34 ++--- .../button/tertiary-button/tertiary-button.ts | 4 +- ...nsparent-button-link.snapshot.spec.snap.js | 1 + .../transparent-button.snapshot.spec.snap.js | 1 - .../button/transparent-button/readme.md | 34 ++--- .../transparent-button/transparent-button.ts | 4 +- .../core/base-elements/link-base-element.ts | 1 + .../core/mixins/disabled-mixin.spec.ts | 126 ++++++++++++++++++ src/elements/core/mixins/disabled-mixin.ts | 37 +++-- .../datepicker-toggle.snapshot.spec.snap.js | 4 +- .../datepicker-toggle/datepicker-toggle.ts | 15 +-- .../expansion-panel-header.ts | 4 +- .../expansion-panel-header/readme.md | 28 ++-- .../expansion-panel.stories.ts | 26 +++- .../block-link-button/block-link-button.ts | 4 +- src/elements/link/block-link-button/readme.md | 34 ++--- .../link/common/link-common-stories.ts | 13 ++ src/elements/link/link-button/link-button.ts | 4 +- src/elements/link/link-button/readme.md | 32 ++--- .../menu/menu-button/menu-button.stories.ts | 11 ++ src/elements/menu/menu-button/menu-button.ts | 4 +- src/elements/menu/menu-button/readme.md | 32 ++--- .../__snapshots__/menu.snapshot.spec.snap.js | 2 - src/elements/menu/menu/menu.ts | 8 +- .../popover-trigger/popover-trigger.spec.ts | 7 +- .../popover-trigger.stories.ts | 8 ++ .../popover-trigger/popover-trigger.ts | 4 +- .../popover/popover-trigger/readme.md | 28 ++-- src/elements/slider/slider.spec.ts | 17 +++ src/elements/slider/slider.ts | 22 +-- .../__snapshots__/tag.snapshot.spec.snap.js | 1 - src/elements/tag/tag/readme.md | 32 +++-- src/elements/tag/tag/tag.stories.ts | 8 ++ src/elements/tag/tag/tag.ts | 4 +- 47 files changed, 494 insertions(+), 231 deletions(-) create mode 100644 src/elements/core/mixins/disabled-mixin.spec.ts diff --git a/src/elements/button/button-link/__snapshots__/button-link.snapshot.spec.snap.js b/src/elements/button/button-link/__snapshots__/button-link.snapshot.spec.snap.js index a6285e81c8..86c17e6626 100644 --- a/src/elements/button/button-link/__snapshots__/button-link.snapshot.spec.snap.js +++ b/src/elements/button/button-link/__snapshots__/button-link.snapshot.spec.snap.js @@ -67,6 +67,7 @@ snapshots["sbb-button-link renders a disabled sbb-button-link with slotted icon aria-disabled="true" class="sbb-action-base sbb-button-link" href="https://www.sbb.ch" + tabindex="-1" > diff --git a/src/elements/button/button/__snapshots__/button.snapshot.spec.snap.js b/src/elements/button/button/__snapshots__/button.snapshot.spec.snap.js index 619bc0bef5..7a6679a059 100644 --- a/src/elements/button/button/__snapshots__/button.snapshot.spec.snap.js +++ b/src/elements/button/button/__snapshots__/button.snapshot.spec.snap.js @@ -14,7 +14,6 @@ snapshots["sbb-button renders a sbb-button without icon DOM"] = negative="" role="button" size="m" - tabindex="0" type="button" value="value" > diff --git a/src/elements/button/button/button.ts b/src/elements/button/button/button.ts index f28717e1a1..f956f86828 100644 --- a/src/elements/button/button/button.ts +++ b/src/elements/button/button/button.ts @@ -2,7 +2,7 @@ import type { CSSResultGroup } from 'lit'; import { customElement } from 'lit/decorators.js'; import { SbbButtonBaseElement } from '../../core/base-elements.js'; -import { SbbFocusableDisabledActionMixin } from '../../core/mixins.js'; +import { SbbDisabledTabIndexActionMixin } from '../../core/mixins.js'; import { buttonCommonStyle, buttonPrimaryStyle, SbbButtonCommonElementMixin } from '../common.js'; /** @@ -13,7 +13,7 @@ import { buttonCommonStyle, buttonPrimaryStyle, SbbButtonCommonElementMixin } fr */ @customElement('sbb-button') export class SbbButtonElement extends SbbButtonCommonElementMixin( - SbbFocusableDisabledActionMixin(SbbButtonBaseElement), + SbbDisabledTabIndexActionMixin(SbbButtonBaseElement), ) { public static override styles: CSSResultGroup = [buttonCommonStyle, buttonPrimaryStyle]; } diff --git a/src/elements/button/button/readme.md b/src/elements/button/button/readme.md index ee6fbec01e..dbb5e5a865 100644 --- a/src/elements/button/button/readme.md +++ b/src/elements/button/button/readme.md @@ -62,28 +62,30 @@ sbb-button { Use the accessibility properties in case of an icon-only button to describe the purpose of the `sbb-button` for screen-reader users. -### Disabled buttons +### Interactive disabled Buttons -Generally speaking, `disabled` elements are considered a bad pattern for accessibility. They are invisible to assistive -technology and do not provide the reason for which they are disabled. -To partially address the problem, disabled elements are kept focusable (other interactions are still prevented). -However, it is still the consumers responsibility to provide a reason for the element being disabled. -This can be achieved by adding an `aria-label`, `aria-labelledby` or `aria-describedby` attribute. +native disabled `