From 88cc8e94d8ddbd571cdf04d4b537874fd39f0abd Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Sat, 20 Jun 2026 23:35:22 +0800 Subject: [PATCH] fix(variables): clamp variant-header hover wash to its hit column A long variant name could make the fit-content variant-header hover wash wider than its column and bleed into the neighbouring variant column. Clamp the wash right edge to the hit column (`col_w.min(176)`), matching the size-checkbox / footer clamps. Wash regression tests moved to a sibling variables_panel/wash_tests.rs (keeps tests.rs under the 800-line cap) with a new long-variant clamp case. --- .../src/widgets/variables_panel.rs | 2 + .../src/widgets/variables_panel/paint.rs | 15 +- .../src/widgets/variables_panel/tests.rs | 85 +---------- .../src/widgets/variables_panel/wash_tests.rs | 135 ++++++++++++++++++ 4 files changed, 149 insertions(+), 88 deletions(-) create mode 100644 crates/op-editor-ui/src/widgets/variables_panel/wash_tests.rs diff --git a/crates/op-editor-ui/src/widgets/variables_panel.rs b/crates/op-editor-ui/src/widgets/variables_panel.rs index 554218fc4..21ac38b38 100644 --- a/crates/op-editor-ui/src/widgets/variables_panel.rs +++ b/crates/op-editor-ui/src/widgets/variables_panel.rs @@ -776,3 +776,5 @@ impl Widget for VariablesPanel { #[cfg(test)] mod tests; +#[cfg(test)] +mod wash_tests; diff --git a/crates/op-editor-ui/src/widgets/variables_panel/paint.rs b/crates/op-editor-ui/src/widgets/variables_panel/paint.rs index fef4a324a..e20db783e 100644 --- a/crates/op-editor-ui/src/widgets/variables_panel/paint.rs +++ b/crates/op-editor-ui/src/widgets/variables_panel/paint.rs @@ -279,13 +279,16 @@ fn paint_variant_header( let variant_width = cx.backend.measure_text(variant, 13.0); // Hover/press wash hugs `value v` (+ small L/R padding) instead of // washing the whole value-column cell. The hit target stays the - // wider `variant_header_rect` so the trigger is still easy to click. + // wider `variant_header_rect` so the trigger is still easy to click, + // and the wash is clamped to that hit column so a long variant name + // can't bleed into the neighbouring variant column. + let wash_left = x - HOVER_WASH_PAD_X; + let cell_right = wash_left + col_w.min(176.0); + let wash_right = + (wash_left + variant_width + 6.0 + 11.0 + HOVER_WASH_PAD_X * 2.0).min(cell_right); let wash = Rect { - origin: Point2D::new(x - HOVER_WASH_PAD_X, header_bottom + 4.0), - size: Point2D::new( - variant_width + 6.0 + 11.0 + HOVER_WASH_PAD_X * 2.0, - 30.0, - ), + origin: Point2D::new(wash_left, header_bottom + 4.0), + size: Point2D::new((wash_right - wash_left).max(0.0), 30.0), }; paint_feedback(panel, cx, VariablesPanelButton::VariantHeader(idx), wash, 8.0); paint_text( diff --git a/crates/op-editor-ui/src/widgets/variables_panel/tests.rs b/crates/op-editor-ui/src/widgets/variables_panel/tests.rs index 424e6adc7..8154c9754 100644 --- a/crates/op-editor-ui/src/widgets/variables_panel/tests.rs +++ b/crates/op-editor-ui/src/widgets/variables_panel/tests.rs @@ -813,85 +813,6 @@ fn axis_chip_table_mirrors_active_theme_btree_order() { assert_eq!(p.chips[1].axis, "z-axis"); } -// ── fit-content hover wash (#26 variant header + #3 add-variable footer) ───── -// -// Both the variant-header value (`Default v`) and the footer `+