Skip to content

Device authorization loses keyboard focus while Approve is pending #46700

Closed

Description

@hyoban

Summary

On the device authorization page, keyboard focus is lost while an approval request is pending, so a keyboard user can't retry after a failure.

Details

In web/app/(auth)/device/components/authorize-account.tsx, the Approve and Deny buttons use the native disabled attribute while busy:

<Button variant="primary" size="large" className="flex-1" onClick={approve} disabled={busy}>

When the focused Approve button becomes disabled, the browser moves focus to <body>. After the request fails, pressing Enter does nothing until the user tabs back to the button.

How to reproduce

  1. Open the device authorization page signed in, and focus Approve with the keyboard.
  2. Press Enter while the approve request is slow and then fails.
  3. Press Enter again: nothing happens, because focus is on <body>.

web/app/(auth)/device/components/__tests__/authorize-account.browser.spec.tsx ("keeps the account and code available after failure and completes a native keyboard retry") fails once the request takes a real round trip, as in #46695.

Expected

Focus stays on the action while the request is pending, for example by using focusableWhenDisabled (or aria-disabled) as other Dify forms already do, so a keyboard retry works after a failure.

Activity

  1. dosubot commented on Nov 18, 2026

    @dosubot

    The shared Button already has a loading prop for this case: it blocks activation while retaining focus and adds a decorative spinner. Its documentation recommends passing pending state to loading, rather than disabled. That provides another option here without manually managing aria-disabled. [1] [2]

    If the spinner is unwanted, keeping disabled={busy} and adding focusableWhenDisabled to both actions uses the same underlying focusability mechanism. [3]

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  2. BlueX888 commented on Nov 18, 2026

    @BlueX888
    Contributor

    Reproduced the focus loss: the native disabled prop moves focus to <body> while the request is pending. The fix follows the Dify UI button contract — pass the pending state as loading (keeps the button focusable with aria-disabled and blocks activation) on both Approve and Deny, with a browser regression test that keeps focus through a failed round trip and retries with Enter. Opening a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions