Skip to content

[slider] Fix thumb :focus-visible with mixed keyboard and pointer modality - #2584

Merged
mj12albert merged 5 commits into
mui:masterfrom
mj12albert:slider/thumb-focus-visible
Aug 28, 2025
Merged

mj12albert merged 5 commits into
mui:masterfrom
mj12albert:slider/thumb-focus-visible

Conversation

@mj12albert

@mj12albert mj12albert commented Aug 26, 2025 •

Copy link
Copy Markdown
Member

Preview

Single thumb: https://deploy-preview-2584--base-ui.netlify.app/react/components/slider

single-thumb.mov

Multiple thumbs: https://deploy-preview-2584--base-ui.netlify.app/react/components/slider#range-slider

multiple-thumbs.mov

Differences from other libraries:

Doesn't work in Firefox due to a browser bug.

Fixes #2512

@mj12albert mj12albert added the component: slider Changes related to the slider component. label Aug 26, 2025
@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2025 •

Copy link
Copy Markdown

vite-css-base-ui-example

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

commit: e4867bd

@mui-bot

mui-bot commented Aug 26, 2025 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 🔺+187B(+0.06%) ▼-7B(-0.01%)

Details of bundle changes

Generated by 🚫 dangerJS against e4867bd

@netlify

netlify Bot commented Aug 26, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit e4867bd
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/68aff82317e8e200088869f5
😎 Deploy Preview https://deploy-preview-2584--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.

@mj12albert mj12albert mentioned this pull request Aug 26, 2025
1 task done
@mj12albert
mj12albert force-pushed the slider/thumb-focus-visible branch from b87bae6 to 28ddfe5 Compare August 27, 2025 06:38
@mj12albert

Copy link
Copy Markdown
Member Author

@atomiks It's not fully fixed in Firefox due to their bug, pointerdown on the thumb will not trigger the focus-visible ring (correctly), but a subsequent keydown fails to trigger the ring (it does in other browsers): https://codesandbox.io/p/sandbox/base-ui-slider-focus-visible-puzzle-7h9v55

@atomiks

atomiks commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

@mj12albert that's a pretty minor detail to begin, with since it's only in FF, it doesn't matter - the fix here looks good

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 28, 2025
@mj12albert
mj12albert force-pushed the slider/thumb-focus-visible branch from 28ddfe5 to 44ebf82 Compare August 28, 2025 04:20
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 28, 2025
@mj12albert mj12albert added the type: bug It doesn't behave as expected. label Aug 28, 2025
@mj12albert
mj12albert marked this pull request as ready for review August 28, 2025 05:06
Comment on lines +382 to +384
const pressedOnFocusedThumb = thumbRefs.current[finger.thumbIndex]?.contains(
activeElement(ownerDocument(control)),
);

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.

Use the contains util, which supports shadow DOM

@mj12albert
mj12albert requested a review from atomiks August 28, 2025 06:37
@mj12albert
mj12albert merged commit 4b0c913 into mui:master Aug 28, 2025
@mj12albert
mj12albert deleted the slider/thumb-focus-visible branch August 28, 2025 06:55
atomiks pushed a commit to atomiks/base-ui that referenced this pull request Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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] Focus styling for slider thumb and the hidden <input />

3 participants