Allow 0 as value in multi-context settings #190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
This accepts 0 values as non-empty for multi-context settings.
Why is it needed?
When using ClientConfig in multi-context mode, you can't set an actual value of 0 (tested with numberfield and selectbox). This causes the setting to fall back on the global value.
I don't know if this is a bug or a design choice, but in my opinion 0 does not always equate to empty here. So I propose to return 0 as context-specific value, instead of the global fallback.
Remarks
I hope this won't break anyone's existing setup. It's also a little tricky to select a truly empty option in a selectbox, because the following doesn't work:
In this case,
Global
is returned if you select the first option. Also a little bug maybe? Because this would work with TVs.. In any case, this does work:This renders and empty first option and when selected, the global value is returned. Not the prettiest solution, but at least it allows you to replicate the old behaviour. A reset option similar to the one for TVs would be nice here of course, but that's probably a little too much to ask for ;)