-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Which Umbraco version are you using?
16.3.4, 17.0.0-rc
Bug summary
When you have a data type that uses a slider that is:
- Not in 'range' mode, so you can only select one value
- Has an initial value defined
- The property that uses the data type is not required
In some cases, the validation in the backoffice fails and you need to manually move the slider to make it valid again, even if it's just to move it out of it's initial value and back again.
Specifics
The reason I found this issue is because we create a data type for a slider for a sitemap in code. It has this config:
new Dictionary<string, object>()
{
{"enableRange", false},
{"minVal", 0.0M},
{"maxVal", 1.0M},
{"initVal1", 0.5M},
{"step", 0.1M}
}The backoffice interface does not allow decimals, but it works fine and is not relevant for this issue. This should create a data type for a slider that should have a default value of 0.5. However, each page a property that uses this slider does not publish without touching the slider first. Which is VERY annoying.
The issue is that the slider property value preset does not handle the enableRange property correctly. It does not actually check the value of the enableRange, but will always return true of the enableRange property is in the configuration.
Why this is usually not a problem:
- If you create a data type using the slider and don't change the enableRange toggle, the configuration will not have the enableRange property, so it will be false in the slider property value preset.
- If you want to have a slider, you'll enable the slider, the enableRange will be in the configuration and will be true in the slider property value preset.
However, it goes wrong when enableRange IS in the configuration:
- When you enable the toggle for range on the data type, but uncheck it again.
- When you (in my case) create a data type in code and set range to false.
Steps to reproduce
Create a new data type based on a slider. Before saving toggle the 'enableRange' a few times.
- Create a new page that has that slider
- Don't touch or change the slider
- Try to publish the page:
This happends because the slider property value preset supplies it with a minValue of 5 and a maxValue of 0. But these should both be 5 for non-ranged sliders.
If you move the slider manually - even if it's just back and forth to the initial value, the validation will go away:
Expected result / actual result
I expect the slider to just work without validation errors so that I can publish the page without touching the slider.