From 873aacbffcb73723b8f34a96f96e6025ee27d69c Mon Sep 17 00:00:00 2001 From: Maanil Verma Date: Wed, 5 Aug 2026 01:33:06 +0530 Subject: [PATCH] fix(ui): keep the button label readable while loading (#14695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > **Stacked PR 2 of 5** — cloud auth redesign. Merge in order, bottom-up. > > | | PR | What it does | > |---|---|---| > | 1 | #14694 | Dark theme, brand tokens, PP Formula shipped cloud-only | > | 2 | #14695 | Button keeps its label for screen readers while loading | > | 3 | #14696 | Brand button variants; login, sign-up and forgot-password rebuilt on them | > | 4 | #14697 | Logo, content and terms share one left edge | > | 5 | #14698 | Static hero collage becomes a video carousel | ## Summary The shared `Button` dropped its label while loading, so assistive tech lost the control name for as long as the request was in flight. ## Changes - **What**: Keeps the label in the accessibility tree via `sr-only`, hides the decorative spinner from screen readers, and marks the control `aria-busy` while loading. Visually unchanged. ## Review Focus `Button.vue` is used app-wide, so the loading change is worth a look beyond the cloud pages — the rendered output is identical, only the accessibility tree differs. This PR is now two files. The locale changes it originally carried moved to the PRs that consume them (auth copy to #14696, carousel keys to #14698), so no intermediate merge renders raw i18n keys. Stacked on #14694. --- src/components/ui/button/Button.test.ts | 9 ++++++--- src/components/ui/button/Button.vue | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/ui/button/Button.test.ts b/src/components/ui/button/Button.test.ts index cb986f98f34..bdc8affd466 100644 --- a/src/components/ui/button/Button.test.ts +++ b/src/components/ui/button/Button.test.ts @@ -27,16 +27,19 @@ describe('Button', () => { expect(onClick).toHaveBeenCalledTimes(1) }) - it('hides slot content, shows a spinner, and disables the button while loading', () => { + // The label stays in the accessibility tree while loading, so the control is + // still announced by name rather than as an unlabelled button. + it('swaps slot content for a spinner and disables the button while loading', () => { const { container } = render(Button, { props: { loading: true }, slots: { default: 'Submit' } }) - expect(screen.queryByText('Submit')).not.toBeInTheDocument() + const button = screen.getByRole('button', { name: 'Submit' }) + expect(button).toBeDisabled() + expect(button).toHaveAttribute('aria-busy', 'true') // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access -- PrimeVue spinner icon has no accessible role expect(container.querySelector('.pi-spin')).toBeInTheDocument() - expect(screen.getByRole('button')).toBeDisabled() }) it('does not fire click when loading', async () => { diff --git a/src/components/ui/button/Button.vue b/src/components/ui/button/Button.vue index bd607238739..d32be57cdad 100644 --- a/src/components/ui/button/Button.vue +++ b/src/components/ui/button/Button.vue @@ -29,9 +29,13 @@ const { :as :as-child :disabled="disabled || loading" + :aria-busy="loading || undefined" :class="cn(buttonVariants({ variant, size }), customClass)" > - - +