react-component / react-component/slider

Slider moves when it receives focus.

Open
#433 5 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.1k
Forks
768
Avg merge
11d 22h
Merged PRs (30d)
5

Description

Hey folks. Thanks for this super sweet slider component.

We're encountering an issue in which the slider moves slightly when it receives focus. In the following GIF, I am simply tabbing through the input elements. Each slider is accompanied by a number input box. When I tab out of a number input box, focus is being given to the slider on the next row. We can see each slider move slightly as this happens.

slider-bug-tabbing-github


In the following GIF, we can see in the console that the <Slider> component is having it's dragging state attribute set to true when it receives focus:

slider-bug-tabbing-dragging-attribute-github


Finally, this GIF shows that when the slider has focus, switching out of the browser window and back in causes the slider to move each time:

slider-bug-tabbing-dragging-attribute-with-window-focus-github


I investigated our own code thoroughly. There is not much to it, and even when it is all commented out, this behavior is still displayed. It is apparent that when the slider receives focus, the <Slider> component's onChange handler is being triggered with a slightly increased value.

I suspected it was incorrectly capturing some sort of mouse event. I found that positioning my mouse cursor to the left or right of the slider made no difference in the behavior. The slider handle always moves to the right the same amount.

For now we are going to work around the problem by removing the element from the tab flow, and eliminating any other code we have that gives the slider focus, but any further insight into this would be super.

Cheers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the component's focus handling and trace why its onChange handler runs when focus is received, using the dragging state described in the issue. Reproduce the tabbing and browser-window focus cases; done means focusing the slider no longer changes its value or sets dragging unexpectedly.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
accessibility, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.