react / react/react

Bug: pseudo styles don't work properly if React state does not change when clicking with right mouse button.

Open
#23,306 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: DOM Type: Bug
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

I have a button that changes background in :hover and :active states. Clicking the button with left mouse button (LMB) works fine, styles change as they should. But, clicking with right mouse button (RMB) works fine only if underlying react state is actually changed (e.g. different from the previous state)

React version: 17.0.2

Steps To Reproduce

  1. Open the code example provided below
  2. Click the "Click Me" button with LMB more than 2 times (DON'T move your mouse cursor while clicking)
  3. Click the "Click Me" button with RMB more than 2 times (DON'T move your mouse cursor while clicking)

Link to code example: https://codesandbox.io/s/pensive-sunset-z1t69f

The current behavior

No mater how many times you click with LMB, the "Click Me" button consistently changes its background color to yellow when you hold LMB down, and changes it back to silver when you release LMB.

The second time RMB pressed down, the background color of the "Click Me" button remains yellow, even if you release RMB. That is, whenever you click it with RMB and the new react state is the same as the previous, the button style remains yellow even if you release RMB.

The expected behavior

Clicking the "Click Me" button with RMB should respect styles regardless of the underlying react state.

Contributor guide

Open the contributing guide

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 with the CodeSandbox example linked in the issue and reproduce the difference between left- and right-button clicks when React state remains unchanged. Trace the button's state updates and pseudo-style behavior, then verify that repeated right-clicks restore the expected styling after release.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.