material-components / material-components/material-web

Switch and Checkbox labels stop working when a text is selected anywhere on the page

Open
#5,138 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
11.3k
Forks
1.1k
Avg merge
20h 28m
Merged PRs (30d)
13

Description

What is affected?

Component

Description

I am not sure if this is related to #5108 or not but this is much easier to reproduce:

https://github.com/material-components/material-web/assets/6388546/128fcf65-e4a4-4847-9cab-33c865fd8a7d

Whenever there is a text selected anywhere in the page (in my app, a text-field content was being selected), the label of md-switch and md-checkbox would stop working. Interestingly md-radio works correctly. In the video, a standard <input type="checkbox" /> is showed where it simply deselect all selecting texts on clicking. Sorry I couldn't show that I was clicking but you could see the first click does provide a visual indicator (the switch changes color a little bit but it doesn't change state).

Reproduction

Lit Playground with md-checkbox, md-radio and md-switch.

Select a text on the label or inside the text-field, then try clicking the label text.

Interestingly, I also cannot reproduce this on Firefox, similar to #5108 but on Firefox, sometimes clicking the Label would deselect the selected text and sometimes it does not, nevertheless, the components work correctly.

Workaround

None that I know of.

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

1.0.1

Browser/OS/Node environment

Microsoft Edge
Version 118.0.2088.76 (Official build) (64-bit)

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 linked Lit Playground reproduction in Microsoft Edge, comparing md-switch and md-checkbox with md-radio and the native checkbox after selecting text. Trace the relevant component behavior and add a regression check; done means the switch and checkbox labels respond correctly after text selection without breaking the other cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.