From 303a4bf744092d199f5a2a605d7c6852f31d0b46 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 21:18:52 +0000 Subject: [PATCH] The contextual-leave strip story reads the frame number, so a measuring run changes none of its values --- crates/ui-widgets/src/tabs/strip/stories.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/ui-widgets/src/tabs/strip/stories.rs b/crates/ui-widgets/src/tabs/strip/stories.rs index f5890c7de..9b0775a36 100644 --- a/crates/ui-widgets/src/tabs/strip/stories.rs +++ b/crates/ui-widgets/src/tabs/strip/stories.rs @@ -150,7 +150,7 @@ fn end_items(rows: &[Entry]) -> [StripEnd<'_>; 2] { const RIBBON_NARROW_ROOM: f32 = 340.0; /// The frames the leave story lists its contextual tab for before the source drops it. -const TABLE_FRAMES: usize = 30; +const TABLE_FRAMES: u64 = 30; #[story(TabStrip<'static, usize>, covers = [], drive = Drive::Never)] fn tab_strip_ribbon(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { @@ -174,11 +174,13 @@ fn tab_strip_ribbon_end_items_narrow(ui: &mut Ui, data: &mut StoryData) -> Story }) } -/// The contextual tab is listed for the first frames and then dropped by the source: it fades out at its slot. +/// The contextual tab is listed for the first frames and then dropped by the source: it fades out at its slot. The +/// story reads the frame it is in rather than counting its runs, so a measuring run or a second pass of one frame +/// lists the same tabs as the frame's other runs. #[story(TabStrip<'static, usize>, covers = [], drive = Drive::Never)] fn tab_strip_ribbon_contextual_leaves(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - let frames = data.value("frames", 0_usize); - *frames += 1; - let open: &[usize] = if *frames <= TABLE_FRAMES { &WITH_TABLE } else { &PLAIN }; + let frame = ui.ctx().cumulative_frame_nr(); + let first = *data.value("first_frame", frame); + let open: &[usize] = if frame.saturating_sub(first) < TABLE_FRAMES { &WITH_TABLE } else { &PLAIN }; ribbon(ui, data, TabStrip::new("Ribbon"), open) }