Skip to content

Commit 2b9d6d2

Browse files
committed
🐛 Fix stale retention slider label when value equals the slider minimum
The FormSlider summary label was only recomputed on value changes, and the Units dependency property defaulted to Hours. When the Minimum binding was applied, it coerced Value (0 -> minimum) and rendered the label while Units was still at its default. If the bound value then equaled the minimum (e.g. an audit retention of exactly 1 day, or error retention of exactly 5 days), no further value change occurred and the label stuck at e.g. "1 Hours". Default Units to Days (the only unit actually used) and refresh the summary whenever Units changes, making the label independent of binding order. The stored setting was never affected; the defect was display-only.
1 parent bdba151 commit 2b9d6d2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/ServiceControl.Config/Xaml/Controls/FormSlider.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ protected override void OnValueChanged(double oldValue, double newValue)
7070
{
7171
base.OnValueChanged(oldValue, newValue);
7272

73+
RefreshSummary();
74+
}
75+
76+
void RefreshSummary()
77+
{
7378
var period = Units == TimeSpanUnits.Days
7479
? TimeSpan.FromDays(Math.Truncate(Value))
7580
: TimeSpan.FromHours(Math.Truncate(Value));
@@ -107,8 +112,12 @@ void UpdateSummary(TimeSpan period)
107112
public static readonly DependencyProperty HeaderProperty =
108113
DependencyProperty.Register("Header", typeof(string), typeof(FormSlider), new PropertyMetadata(string.Empty));
109114

115+
// The summary label is computed in OnValueChanged, which can fire before the Units binding is
116+
// applied (e.g. when the Minimum binding coerces Value). Refresh the summary when Units changes
117+
// so the label never sticks with a unit it was not meant to use.
110118
public static readonly DependencyProperty UnitsProperty =
111-
DependencyProperty.Register("Units", typeof(TimeSpanUnits), typeof(FormSlider));
119+
DependencyProperty.Register("Units", typeof(TimeSpanUnits), typeof(FormSlider),
120+
new PropertyMetadata(TimeSpanUnits.Days, (d, _) => ((FormSlider)d).RefreshSummary()));
112121
}
113122

114123
public enum TimeSpanUnits

0 commit comments

Comments
 (0)