From c1c5d41fa3ff23903d0dacf729b82cb704387fb5 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 16:25:42 +0000 Subject: [PATCH] rc-chrome-w3: red round 1 fix (chrome-run-1-fw) --- crates/ui-contract/src/primitives/text_adapter.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ui-contract/src/primitives/text_adapter.rs b/crates/ui-contract/src/primitives/text_adapter.rs index 62f8bdf94..5daac3b00 100644 --- a/crates/ui-contract/src/primitives/text_adapter.rs +++ b/crates/ui-contract/src/primitives/text_adapter.rs @@ -153,7 +153,8 @@ pub(crate) struct AdapterIn<'a> { pub held: bool, pub ink: egui::Color32, pub intents: &'a mut Intents, - /// A list the component opened on the text is shown (a dropdown, the completions): Escape is the list's. + /// A list the component opened on the text is shown (a dropdown, the completions): Escape is the list's, except + /// in a clearing field that still shows text. pub list_open: bool, pub placeholder: Option<&'a str>, /// Whether the caret stroke shows, from the blink. @@ -467,10 +468,12 @@ pub(crate) fn run(state: &mut TextState, mut input: AdapterIn<'_>) -> AdapterOut Some(DraftChange::Revert) => state.end = Some(End::Revert), None => {} } - // A clearing field takes Escape while it shows text, with or without a draft, and passes it on once it is empty. + // A clearing field takes Escape while it shows text, with or without a draft, and passes it on once it is empty: + // a list open on it (a search box's results) then gets the Escape that finds the field empty and closes. let takes_escape = if input.options.clear_on_escape { !base.is_empty() || state.preedit.is_some() } else { state.draft.is_some() || state.preedit.is_some() }; - if focused_before && takes_escape && !state.completions.open && !input.list_open && input.intents.take(Intent::Cancel) { + let list_first = input.list_open && !input.options.clear_on_escape; + if focused_before && takes_escape && !state.completions.open && !list_first && input.intents.take(Intent::Cancel) { // Escape over a composition alone ends the composition and leaves the text. if state.draft.is_some() || state.preedit.is_none() { state.end = Some(End::Escape);