diff --git a/crates/ui-widgets/src/form/stories.rs b/crates/ui-widgets/src/form/stories.rs index 217500c7c..cf52f2059 100644 --- a/crates/ui-widgets/src/form/stories.rs +++ b/crates/ui-widgets/src/form/stories.rs @@ -40,10 +40,13 @@ fn field_long_text(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { /// A number field whose side label is a link: a click reports to the host and leaves focus alone, a drag scrubs. #[story(Field, covers = [], drive = Drive::Never)] fn field_link_label(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - Field::new("Opacity") + let shown = Field::new("Opacity") .side(SideLabel::new().link().scrub(true)) - .show(ui, |ui, _| NumberField::new("Opacity", data.bind("link", Some(100.0))).scrub_by_label().show(ui)) - .into() + .show(ui, |ui, _| NumberField::new("Opacity", data.bind("link", Some(100.0))).scrub_by_label().show(ui)); + // The field the label names reports the link click; the story is its host. + let link = shown.inner.as_ref().is_some_and(|field| field.link); + let facts = StoryOutput::from(shown); + StoryOutput { clicked: facts.clicked || link, ..facts } } /// A glyph label: the icon shows, the text only names the control. diff --git a/crates/ui-widgets/src/text/linked.rs b/crates/ui-widgets/src/text/linked.rs index 477a5880c..4522ec63c 100644 --- a/crates/ui-widgets/src/text/linked.rs +++ b/crates/ui-widgets/src/text/linked.rs @@ -113,7 +113,8 @@ impl Outcome for LinkedOutput { #[cfg(feature = "testing")] fn story_facts(&self) -> crate::testing::StoryOutput { - self.edit.story_facts() + let facts = self.edit.story_facts(); + crate::testing::StoryOutput { clicked: facts.clicked || self.caption_link.is_some(), ..facts } } } diff --git a/crates/ui-widgets/src/text/number/value.rs b/crates/ui-widgets/src/text/number/value.rs index 6c4026edd..6c2755ec5 100644 --- a/crates/ui-widgets/src/text/number/value.rs +++ b/crates/ui-widgets/src/text/number/value.rs @@ -180,6 +180,7 @@ impl Outcome for NumberOutput { #[cfg(feature = "testing")] fn story_facts(&self) -> crate::testing::StoryOutput { - self.edit.story_facts() + let facts = self.edit.story_facts(); + crate::testing::StoryOutput { clicked: facts.clicked || self.link, ..facts } } }