Skip to content

Treat zero as String in number selector#8070

Merged
bramkragten merged 2 commits intohome-assistant:devfrom
spacegaier:issue-8054
Jan 4, 2021
Merged

Treat zero as String in number selector#8070
bramkragten merged 2 commits intohome-assistant:devfrom
spacegaier:issue-8054

Conversation

@spacegaier
Copy link
Copy Markdown
Member

@spacegaier spacegaier commented Jan 2, 2021

Breaking change

Proposed change

The problem is that currently the slider change returns 0 which leads to a reset to the default value, I assume here:

.value=${(this.config.use_blueprint.input &&
this.config.use_blueprint.input[key]) ||
value?.default}

We now check for "??" before applying the default value again, so that falsy values such as "0" do no longer get overwritten.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@bramkragten
Copy link
Copy Markdown
Member

use ?? instead of || to check for undefined values.

?? checks for undefined or null.
|| checks for falsy (so, 0, undefined, "", null, false, etc.)

@spacegaier
Copy link
Copy Markdown
Member Author

use ?? instead of || to check for undefined values.

?? checks for undefined or null.
|| checks for falsy (so, 0, undefined, "", null, false, etc.)

That is way more elegant 👍 ! Thanks for the hint!

@spacegaier spacegaier requested a review from bramkragten January 4, 2021 09:30
@bramkragten bramkragten merged commit d5a77ef into home-assistant:dev Jan 4, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2021
@spacegaier spacegaier deleted the issue-8054 branch January 5, 2021 11:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blueprints - Cannot set number selector to 0 when using slider

3 participants