Skip to content

[slider] Remove extra TalkBack focus targets - #4242

Merged
atomiks merged 8 commits into
mui:masterfrom
atomiks:codex/fix-slider-talkback-2575
Mar 25, 2026
Merged

atomiks merged 8 commits into
mui:masterfrom
atomiks:codex/fix-slider-talkback-2575

Conversation

@atomiks

@atomiks atomiks commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2575

Removing the tabIndex={-1} from both wrappers makes TalkBack land on the actual input[type="range"] only, which is the element that correctly handles increase/decrease actions

Preview: https://deploy-preview-4242--base-ui.netlify.app/react/components/slider

@atomiks atomiks added component: slider Changes related to the slider component. type: bug It doesn't behave as expected. accessibility a11y labels Mar 3, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 3, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4242
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4242
    

commit: fd5c71b

@atomiks
atomiks requested a review from oliviertassinari March 3, 2026 07:23
@mui-bot

mui-bot commented Mar 3, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+216B(+0.05%) 🔺+63B(+0.04%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Mar 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit fd5c71b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69c33a2c04d60e000805bc52
😎 Deploy Preview https://deploy-preview-4242--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks marked this pull request as ready for review March 3, 2026 07:25
@mj12albert

mj12albert commented Mar 3, 2026 •

Copy link
Copy Markdown
Member

In Firefox:

  • This PR: pointer always triggers the focus visible style
  • master: pointer never triggers focus visible, but keyboard after pointer (incorrectly) never triggers focus visible

Since Firefox is weird either way it's probably OK if it fixes the issue for TalkBack

@mj12albert
mj12albert requested a review from LukasTy March 3, 2026 07:50
@atomiks

atomiks commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

This PR: pointer always triggers the focus visible style

Not always, only if you've never interacted with another focusable element before. (Same as the issue we had some time ago.)

That said, FF supports focusVisible in .focus() broadly, so we can actually just use that 👍

@michaldudak

Copy link
Copy Markdown
Member

Code review

Found 1 issue:

  1. New test code uses chai and sinon instead of vitest-native equivalents. SliderControl.test.tsx introduces a fresh import { expect } from 'chai' (previously the file had no chai dependency), and SliderThumb.test.tsx uses chai-style assertions in the newly added tests. AGENTS.md says: "The repository is transitioning from chai and sinon, prefer vitest native functions for all new code." The fix is to use vitest's expect (imported from 'vitest') and replace .not.to.have.attribute('tabindex') with .not.toHaveAttribute('tabindex'), etc.

import { expect } from 'chai';
import { screen } from '@mui/internal-test-utils';
import { Slider } from '@base-ui/react/slider';
import { createRenderer, describeConformance } from '#test-utils';

</Slider.Root>,
);
expect(screen.getByTestId('thumb')).not.to.have.attribute('tabindex');
expect(screen.getByRole('slider')).to.have.property('tabIndex', 0);

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@atomiks

atomiks commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review (GPT-5.4)

This remains a narrow slider bug-fix PR, and I reviewed the full rebased branch diff against freshly fetched upstream/master. The current head now addresses the earlier follow-up concern as well: the internal focus-visible promotion path is covered by a regression that ensures it does not emit spurious blur/focus side effects.

1. Remaining Bugs / Issues (None)

2. Root Cause & Patch Assessment

The runtime shape now looks coherent for the bug this PR is trying to fix. Pointer-driven focusing still suppresses :focus-visible from the control-side path, while keyboard-driven slider interaction can promote the already-focused range input back into a :focus-visible state through the thumb-side refocus path.

The latest follow-up also tightens that path by suppressing bubbled onBlur/onFocus noise from the internal blur/refocus cycle, so the implementation detail does not leak through the public thumb event handlers.

3. Edge Cases Worth Noting

The non-obvious part of the patch is still the guarded blur/refocus used to restore :focus-visible. That branch is now better protected because the thumb test suite covers both the visible focus-ring behavior and the absence of extra public blur/focus events during the internal handoff.

4. Test Coverage Assessment

Validation I ran on the current rebased head:

  • pnpm typescript
  • pnpm test:chromium SliderThumb --no-watch
  • pnpm test:chromium SliderRoot --no-watch
  • pnpm test:jsdom SliderThumb --no-watch
  • pnpm test:jsdom SliderRoot --no-watch
  • pnpm test:jsdom SliderControl --no-watch

The key coverage improvement is the new browser regression in packages/react/src/slider/thumb/SliderThumb.test.tsx, which exercises the pointer-then-keyboard path and asserts that the internal focus-visible restoration does not generate an extra onBlur/onFocus pair.

5. Previous Review Issues Status

Resolved: the earlier review note about newly introduced chai-style assertions was addressed, and the later follow-up concern about missing coverage for the blur-suppression branch is now covered by the new thumb-level regression. The branch also includes the follow-up typecheck fix and has been rebased onto current upstream/master.

Merge Confidence Score

Overall merge confidence is 4/5. I’m highly confident in the current patch: the full rebased diff is still small, the critical browser-specific interaction path has direct Chromium coverage, and I did not find any remaining correctness issue in the branch review. The residual risk is mostly the usual browser nuance around nonstandard focusVisible behavior rather than a concrete gap in this implementation.

@atomiks
atomiks force-pushed the codex/fix-slider-talkback-2575 branch from 5b67122 to c6a6eaf Compare March 25, 2026 01:25
@atomiks

atomiks commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

I manually verified this works in TalkBack now. :focus-visible issues are resolved across browsers as well.

@atomiks
atomiks merged commit ce22c16 into mui:master Mar 25, 2026
7 checks passed
@atomiks
atomiks deleted the codex/fix-slider-talkback-2575 branch March 25, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility a11y component: slider Changes related to the slider component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[slider] Broken TalkBack support

4 participants