Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make slider value non-nullable #22444

Closed
thw0rted opened this issue Apr 9, 2021 · 4 comments · Fixed by #22912
Closed

Make slider value non-nullable #22444

thw0rted opened this issue Apr 9, 2021 · 4 comments · Fixed by #22912
Assignees
Labels
area: material/slider P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@thw0rted
Copy link

thw0rted commented Apr 9, 2021

Documentation Feedback

The linked docs give the type of value as number | null but the overview never describes a state when the value can actually be null. They say "The initial value is set to the minimum value unless otherwise specified".

If the value actually can be null, an example of this should be provided. If the value is never null (which seems to make more sense?) then the API should be updated so that value is simply number.

Affected documentation page: https://material.angular.io/components/slider/api

@thw0rted thw0rted added docs This issue is related to documentation needs triage This issue needs to be triaged by the team labels Apr 9, 2021
@crisbeto
Copy link
Member

crisbeto commented Apr 9, 2021

I think that a null can be assigned here if the reset method of the related FormControl is called. Changing the type shouldn't be a problem, but it could be considered a breaking change at this point.

@thw0rted
Copy link
Author

thw0rted commented Apr 9, 2021

That's interesting, it didn't occur to me that the default for FormControl must always be null. Aren't there native controls whose value cannot be null? I feel like this came up on another issue recently but I'm having trouble remembering which.

ETA: might have been thinking of <input type=range> since the MDN page says

The value attribute contains a DOMString which contains a string representation of the selected number. The value is never an empty string ("").

(It's always a string, never null, never the empty string.)

@crisbeto
Copy link
Member

We've handled similar cases in other components by setting it to zero when null is passed in. It's just that updating the type now would be breaking.

@crisbeto crisbeto added area: material/slider P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed docs This issue is related to documentation needs triage This issue needs to be triaged by the team labels Apr 12, 2021
@crisbeto crisbeto changed the title docs-bug(MatSlider): When can value be null? Make slider value non-nullable Apr 12, 2021
@crisbeto crisbeto self-assigned this Jun 7, 2021
@crisbeto crisbeto added the has pr label Jun 7, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 7, 2021
Makes the value of the slider a `number`, rather than `number | null` in order to make it easier to use.

Fixes angular#22444.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 7, 2021
Makes the value of the slider a `number`, rather than `number | null` in order to make it easier to use.

Fixes angular#22444.
wagnermaciel pushed a commit that referenced this issue Jun 10, 2021
Makes the value of the slider a `number`, rather than `number | null` in order to make it easier to use.

Fixes #22444.
wagnermaciel pushed a commit that referenced this issue Jun 10, 2021
Makes the value of the slider a `number`, rather than `number | null` in order to make it easier to use.

Fixes #22444.

(cherry picked from commit 71afc46)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/slider P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants