From 24da379ea657f20b24f2fcaaf25b8953b3555824 Mon Sep 17 00:00:00 2001 From: Material Web Team Date: Tue, 9 Jul 2024 08:10:01 -0700 Subject: [PATCH] feat: add `alwaysFocusable` property to button and iconbutton Aligns with the `alwaysFocusable` property that's currently provided by chip. Fixes #5672. PiperOrigin-RevId: 650632329 --- button/internal/button.ts | 13 +++- button/internal/button_test.ts | 71 +++++++++++++++++++ docs/components/button.md | 24 ++++++- iconbutton/internal/_filled-icon-button.scss | 17 +++-- .../internal/_filled-tonal-icon-button.scss | 17 +++-- iconbutton/internal/_icon-button.scss | 8 ++- .../internal/_outlined-icon-button.scss | 16 +++-- iconbutton/internal/icon-button.ts | 13 +++- iconbutton/internal/icon-button_test.ts | 71 +++++++++++++++++++ 9 files changed, 224 insertions(+), 26 deletions(-) create mode 100644 button/internal/button_test.ts create mode 100644 iconbutton/internal/icon-button_test.ts diff --git a/button/internal/button.ts b/button/internal/button.ts index 7037f80b92..bbde5f8c02 100644 --- a/button/internal/button.ts +++ b/button/internal/button.ts @@ -51,6 +51,16 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter { */ @property({type: Boolean, reflect: true}) disabled = false; + /** + * When true, allows disabled buttons to be focused. + * + * Add this when a button needs increased visibility when disabled. See + * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls + * for more guidance on when this is needed. + */ + @property({type: Boolean, attribute: 'always-focusable'}) + alwaysFocusable = false; + /** * The URL that the link button points to. */ @@ -154,7 +164,8 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter { return html`