mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 03:17:43 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user