ui-widgets: a click on a field's link label is the click its output reports to a story

NumberFieldOutput and LinkedOutput reported the link click to the host but not in their story facts, so the suite saw
an AccessKit Click on a link label do nothing. The Field story passes its field's link click on.
This commit is contained in:
bflatastic
2026-11-22 08:03:00 +07:00
parent 2257be8f60
commit 1f7df2dd4d
3 changed files with 10 additions and 5 deletions
+6 -3
View File
@@ -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.
+2 -1
View File
@@ -113,7 +113,8 @@ impl<const N: usize> Outcome for LinkedOutput<N> {
#[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 }
}
}
+2 -1
View File
@@ -180,6 +180,7 @@ impl<V: NumberValue> Outcome for NumberOutput<V> {
#[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 }
}
}