Skip to content

fix(registry): show the elastic slider focus ring only for keyboard focus - #54

Merged
moshiur01 merged 1 commit into
mainfrom
fix/elastic-slider-focus-ring
Nov 17, 2026
Merged

moshiur01 merged 1 commit into
mainfrom
fix/elastic-slider-focus-ring

Conversation

@moshiur01

Copy link
Copy Markdown
Contributor

What

The focus ring around the Elastic Slider's ruler showed up on every mouse press and drag. It should only show for keyboard focus.

Why it happened. Pressing the ruler calls focus() on the hidden <input type="range"> so the arrow keys keep working after a drag. Browsers treat that programmatic focus as :focus-visible, so the ring drew on mouse use too.

The fix. The ring now follows a keyboardFocus state instead of peer-focus-visible:

  • It turns on when the input is focused from the keyboard (Tab), or on any key press, so it comes back as soon as you use the keys after a drag.
  • It turns off on pointer down and on blur.

Focus still moves to the input on press, so the keyboard keeps working straight after a drag.

Tests

  • The ring shows when the slider is focused from the keyboard.
  • It stays hidden when the ruler is pressed with the mouse, while the input still gets focus.
  • It comes back on a key press after a drag.
  • It hides on blur.

I checked the mouse test catches the bug: with the pointer check removed, it fails. The PointerEvent polyfill moved to file level so the pointer tests send a real clientX.

Checks

  • pnpm registry:build passes
  • pnpm typecheck passes
  • Full test suite: 1404 tests pass
  • Not checked in a browser

…ocus

Pressing or dragging the ruler focuses the hidden range input so the
keys keep working, but that programmatic focus matched :focus-visible
and drew the ring on every mouse drag. The ring now follows a
keyboardFocus state: on for Tab focus or any key press, off on pointer
down and blur.

Co-Authored-By: Claude <noreply@anthropic.com>
@moshiur01
moshiur01 merged commit 448a2f9 into main Nov 17, 2026
1 check passed
@moshiur01
moshiur01 deleted the fix/elastic-slider-focus-ring branch November 17, 2026 05:40
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.

1 participant