Skip to content

Remove disabled toggle from the tab order#319693

Merged
connor4312 merged 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/find-widget-disabled-toggle-tabindex
Jun 4, 2026
Merged

Remove disabled toggle from the tab order#319693
connor4312 merged 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/find-widget-disabled-toggle-tabindex

Conversation

@yogeshwaran-c

Copy link
Copy Markdown
Contributor

Fixes #147299

Problem

After invoking Find once (or toggling any of the option buttons via their keybinding, e.g. Alt+C), the find widget's Match Case, Match Whole Word, Use Regular Expression and Preserve Case toggles stay in the editor's tab order even while the find widget is hidden. With Tab Moves Focus (Ctrl+M) enabled this is easy to observe: tabbing from the editor lands on these hidden toggles instead of going straight to the status bar. The buttons even flash into view when activated with Space/Enter.

Root cause

When the find widget is hidden it disables its find/replace input (FindInput.setEnabled(false)Toggle.disable()). However Toggle.disable() only set aria-disabled and the disabled class — it never removed the element from the tab order, so tabIndex stayed 0. A disabled toggle is also a no-op on click/keydown (both handlers early-return when not enabled), so being reachable via Tab serves no purpose.

This differs from SimpleButton (the close/prev/next/replace buttons in the same widget), whose setEnabled already toggles tabIndex between 0 and -1.

Fix

Toggle.enable()/disable() now manage tabIndex so a disabled toggle is taken out of the tab order and restored when re-enabled. Toggles created with notFocusable (e.g. toolbar action items that use a roving tabindex via ToggleActionViewItem) are left untouched so their externally managed tabIndex is preserved.

Added unit tests covering both the focusable and notFocusable cases.

A disabled `Toggle` only set `aria-disabled` and the `disabled` class but
kept `tabIndex=0`, so it stayed reachable via Tab even though clicking or
pressing it is a no-op while disabled. This is most visible in the editor
find widget: after using Find once, the Match Case / Match Whole Word /
Use Regular Expression / Preserve Case toggles remain in the tab order even
while the widget is hidden (their owning input is disabled when hidden).

Make `enable()`/`disable()` manage `tabIndex` so a disabled toggle is taken
out of the tab order, matching the behaviour of `SimpleButton` in the find
widget. Toggles created with `notFocusable` (e.g. toolbar action items that
use a roving tabindex) keep their externally managed `tabIndex`.

Fixes microsoft#147299
Copilot AI review requested due to automatic review settings June 3, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds tab-order behavior for Toggle when enabling/disabling, and introduces browser UI tests to validate focusability behavior (including notFocusable toggles).

Changes:

  • Update Toggle.enable() / Toggle.disable() to adjust tabIndex when the toggle is focusable.
  • Add tests covering tabIndex changes for focusable vs notFocusable toggles.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/vs/base/test/browser/ui/toggle/toggle.test.ts Adds regression tests asserting correct tabIndex behavior across enable/disable for focusable and notFocusable toggles.
src/vs/base/browser/ui/toggle/toggle.ts Implements tabIndex updates on enable/disable for focusable toggles while leaving notFocusable toggles untouched.

Comment thread src/vs/base/browser/ui/toggle/toggle.ts
Comment thread src/vs/base/test/browser/ui/toggle/toggle.test.ts
@connor4312 connor4312 enabled auto-merge June 4, 2026 14:01
@connor4312 connor4312 merged commit 9cb066c into microsoft:main Jun 4, 2026
25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find widget buttons become focusable while hidden after using Find once

4 participants