Skip to content

fix(web): keep focus on pending device authorization actions - #46701

Merged
lyzno1 merged 1 commit into
langgenius:mainfrom
BlueX888:contrib/device-approve-focus
Nov 18, 2026
Merged

lyzno1 merged 1 commit into
langgenius:mainfrom
BlueX888:contrib/device-approve-focus

Conversation

@BlueX888

Copy link
Copy Markdown
Contributor

Fixes #46700.

Problem

On the device authorization page, Approve and Deny used the native disabled attribute while busy. When the focused Approve button becomes natively disabled, Chromium moves focus to <body>; after a failed request, pressing Enter no longer activates the action and the user must tab back to it. The SSO branch of the same page had the same bug on its Approve action.

Fix

Pass the pending state to the Dify UI button's loading prop instead of disabled, as the button contract prescribes: activation is blocked, the button stays in the tab order with aria-disabled, focus is retained, and the decorative spinner shows. The label text is unchanged. Both account actions and the SSO Approve action use the same pending state.

Test

New browser cases in authorize-account.browser.spec.tsx and authorize-sso.browser.spec.tsx:

  • starts an approve request that does not resolve, clicks Approve, and asserts the button exposes aria-disabled="true" while document.activeElement is still the button;
  • rejects the request, waits for the error message, and asserts focus never left the button;
  • presses Enter and asserts the retry reaches the success screen and the service was called twice.

The SSO case follows the same steps on its own component.

Both new cases fail on the parent commit (focus lands on <body> while pending) and pass with the change; each spec file reports 4 passed. vp check --no-lint (format + type check) and vp lint are clean on the changed files.

This was prepared by an AI agent (Claude Code) operating the BlueX888 GitHub account; the account owner takes responsibility for the submission.

From Claude Code

The Approve and Deny buttons used the native disabled attribute while a
request was pending, so the browser moved focus to <body> and a keyboard
user could not retry after a failure. Pass the pending state as loading,
which keeps the button focusable with aria-disabled and still blocks
activation, and cover the focus-through-failure path in the browser
spec.
@github-actions github-actions Bot added size:M This PR changes 30-99 lines, ignoring generated files. web This relates to changes on the web. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26%. Comparing base (f1ed2e7) to head (0a7cabb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #46701   +/-   ##
=======================================
  Coverage   90.26%   90.26%           
=======================================
  Files        6452     6452           
  Lines      407038   407038           
  Branches    81756    81756           
=======================================
+ Hits       367409   367421   +12     
+ Misses      33226    33214   -12     
  Partials     6403     6403           
Flag Coverage Δ
dify-ui 92.65% <ø> (ø)
web 90.31% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lyzno1
lyzno1 added this pull request to the merge queue Nov 18, 2026
Merged via the queue into langgenius:main with commit b45e8d5 Nov 18, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device authorization loses keyboard focus while Approve is pending

2 participants