material-components / material-components/material-web

Add coercing to properties to ensure type safety (`disabled = undefined || null` is not supported)

Open
#5,357 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What is affected?

Component

Description

When I set disabled to undefined on an md-slider, the slider is disabled.

Reproduction

https://lit.dev/playground/#project=W3sibmFtZSI6Im15LWV4YW1wbGUudHMiLCJjb250ZW50IjoiaW1wb3J0IHtodG1sLCBjc3MsIExpdEVsZW1lbnR9IGZyb20gJ2xpdCc7XG5pbXBvcnQge2N1c3RvbUVsZW1lbnR9IGZyb20gJ2xpdC9kZWNvcmF0b3JzLmpzJztcbmltcG9ydCAnQG1hdGVyaWFsL3dlYi9zbGlkZXIvc2xpZGVyJztcblxuQGN1c3RvbUVsZW1lbnQoJ215LWV4YW1wbGUnKVxuZXhwb3J0IGNsYXNzIE15RXhhbXBsZSBleHRlbmRzIExpdEVsZW1lbnQge1xuICBzdGF0aWMgc3R5bGVzID0gY3NzYFxuICAgIGlucHV0IHtcbiAgICAgIGRpc3BsYXk6IGJsb2NrO1xuICAgIH1cbiAgYDtcbiAgXG4gIHJlbmRlcigpIHtcbiAgICByZXR1cm4gaHRtbGBcbiAgICAgIDxtZC1zbGlkZXIgLmRpc2FibGVkPSR7bnVsbH0-PC9tZC1zbGlkZXI-XG4gICAgICA8bWQtc2xpZGVyIC5kaXNhYmxlZD0ke3VuZGVmaW5lZH0-PC9tZC1zbGlkZXI-XG4gICAgICA8aW5wdXQgdHlwZT1cInRleHRcIiAuZGlzYWJsZWQ9JHtudWxsfSAvPlxuICAgICAgPGlucHV0IHR5cGU9XCJ0ZXh0XCIgLmRpc2FibGVkPSR7dW5kZWZpbmVkfSAvPlxuICAgIGA7XG4gIH1cbn1cbiJ9LHsibmFtZSI6ImluZGV4Lmh0bWwiLCJjb250ZW50IjoiPCFET0NUWVBFIGh0bWw-XG48aGVhZD5cbiAgPHNjcmlwdCB0eXBlPVwibW9kdWxlXCIgc3JjPVwiLi9teS1leGFtcGxlLmpzXCI-PC9zY3JpcHQ-XG48L2hlYWQ-XG48Ym9keT5cbiAgPG15LWV4YW1wbGU-PC9teS1leGFtcGxlPlxuPC9ib2R5PlxuIn0seyJuYW1lIjoicGFja2FnZS5qc29uIiwiY29udGVudCI6IntcbiAgXCJkZXBlbmRlbmNpZXNcIjoge1xuICAgIFwibGl0XCI6IFwiXjMuMC4wXCIsXG4gICAgXCJAbGl0L3JlYWN0aXZlLWVsZW1lbnRcIjogXCJeMi4wLjBcIixcbiAgICBcImxpdC1lbGVtZW50XCI6IFwiXjQuMC4wXCIsXG4gICAgXCJsaXQtaHRtbFwiOiBcIl4zLjAuMFwiXG4gIH1cbn0iLCJoaWRkZW4iOnRydWV9XQ

Workaround

Set disabled to null instead of undefined to disable a slider.

Is this a regression?

Yes. This used to work, but now it doesn't.

Affected versions

1.1.1

Browser/OS/Node environment

Browser: Firefox 121.0
OS: macOS 14.2

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 md-slider cases in the linked Lit playground reproduction and compare them with the adjacent input examples using undefined and null. Trace the slider's property handling, then verify that the reported undefined/null behavior matches the intended semantics described in the issue. Done means the reproduction behaves correctly and a regression test covers it if component tests exist.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.