fix(ColorPicker): correct gradient track active thumb property owner

This commit is contained in:
chinboy
2026-05-23 22:42:47 +08:00
parent 5f8c583656
commit b170b4b469
2 changed files with 16 additions and 2 deletions
@@ -13,7 +13,7 @@ internal class GradientColorPickerTrack : AbstractColorPickerSliderTrack
GradientColorSlider.GradientValueProperty.AddOwner<GradientColorPickerTrack>();
public static readonly StyledProperty<GradientColorSliderThumb?> ActivatedThumbProperty =
AvaloniaProperty.Register<GradientColorSlider, GradientColorSliderThumb?>(nameof(ActivatedThumb));
AvaloniaProperty.Register<GradientColorPickerTrack, GradientColorSliderThumb?>(nameof(ActivatedThumb));
public LinearGradientBrush? GradientValue
{
@@ -369,4 +369,4 @@ internal class GradientColorPickerTrack : AbstractColorPickerSliderTrack
public void Dispose() => _owner._ignoringPropertyChanged = false;
}
}
}
@@ -14,6 +14,7 @@ internal static partial class Program
VerifyColorPickerHoverIgnoresClickHandler(failures);
VerifyColorPickerFocusTrigger(failures);
VerifyColorPickerTriggerSubscriptionLifecycle(failures);
VerifyGradientColorPickerTrackPropertyOwner(failures);
if (failures.Count == 0)
{
@@ -99,6 +100,19 @@ internal static partial class Program
failures);
}
private static void VerifyGradientColorPickerTrackPropertyOwner(ICollection<string> failures)
{
var trackType = Type.GetType(
"AtomUI.Desktop.Controls.GradientColorPickerTrack, AtomUI.Desktop.Controls.ColorPicker");
var property = trackType?
.GetField("ActivatedThumbProperty", BindingFlags.Public | BindingFlags.Static)?
.GetValue(null) as Avalonia.AvaloniaProperty;
Expect(trackType is not null && property?.OwnerType == trackType,
$"GradientColorPickerTrack.ActivatedThumbProperty should be registered on GradientColorPickerTrack. Actual owner: {property?.OwnerType.FullName ?? "<null>"}.",
failures);
}
private static bool GetColorPickerIsOpen(AbstractColorPicker picker)
=> GetColorPickerProperty<bool>(picker, "IsPickerOpen");