An edit response carries the component's pointer stay; the combo box preview story reports the preview in its readout, not its data; layer-trap DIAG for the companion story

This commit is contained in:
Martin Ball
2026-11-18 21:18:12 +00:00
parent 4a074a072f
commit 7016c8a3e0
3 changed files with 20 additions and 4 deletions
@@ -245,6 +245,7 @@ impl<C: Component> Edit for Cx<'_, C> {
response.caret = self.core.texts.as_ref().and_then(|(_, text)| text.caret());
response.unparsed = self.core.text_invalid;
response.value_text = self.core.value_text.borrow().clone();
response.hover = self.core.hover();
response.shown = match (&self.shown, self.mixed) {
(_, true) => Some(Mixed::Mixed),
(Some(value), false) => Some(Mixed::Same(Arc::clone(value))),
@@ -130,6 +130,18 @@ pub(super) fn layer_traps_focus(subject: &Subject) -> Result<(), String> {
for step in 0..stops + 2 {
fixture.key(Key::Tab, Modifiers::NONE);
if !focus_within(&fixture, container.node) {
if story.name == "menu_with_companion" {
let tree = fixture.tree();
let focused = tree.focused_key();
eprintln!(
"DIAG layer_traps_focus: focused {:?} role {:?} name {:?}; container {:?} role {:?}; scope trap {traps}",
focused,
tree.role_of(focused),
crate::testing::access::name(tree, focused),
container.node,
tree.role_of(container.node)
);
}
return Err(format!("{}: Tab number {} moved focus out of the layer", story.name, step + 1));
}
}
@@ -68,9 +68,12 @@ fn hover_option(fixture: &mut Fixture) {
fn combo_box_preview(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let options = options();
let shown = ComboBox::new("Font", Bind::bound(data.value("preview_font", "Charter".to_owned())), &options).show(ui);
// The field keeps "Charter" while the hovered option is previewed; the story keeps what the preview shows.
if shown.preview != Preview::Unchanged {
*data.value("previewed", Preview::<String>::Unchanged) = shown.preview.clone();
// The field keeps "Charter" while the hovered option is previewed. The preview is no edit, so the story says what
// it shows in its readout, not in its data, which a drive reads as a changed value.
let output = StoryOutput::from(shown.edit);
match shown.preview {
Preview::Shows(text) => output.readout(format!("Previewing {text}")),
Preview::Ended => output.readout("Preview ended"),
_ => output,
}
shown.edit.into()
}