* claim: #7190 * Report a bug: focus the empty description once, not every frame (#7190) After Continue on GitHub found What happened? empty, the form moved the focus back to it on every frame, so typing in Summary went into the description. Continue now re-arms the one-time focus (and scroll into view) instead; the other fields stay free to type in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,8 @@ pub struct Draft {
|
||||
texture: Option<TextureHandle>,
|
||||
pub note: String,
|
||||
source_signature: u64,
|
||||
/// The description has taken the focus it gets on opening; Continue finding it empty clears
|
||||
/// this, so it takes the focus once more (#7190).
|
||||
focus_requested: bool,
|
||||
missing_description: bool,
|
||||
opened_github: bool,
|
||||
@@ -844,6 +846,32 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Continue with an empty description gives it the focus once (#7190). It used to take the
|
||||
/// focus back every frame, so what was typed in Summary went into the description.
|
||||
#[test]
|
||||
fn issue_report_empty_description_takes_the_focus_once() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.issue_report.draft = Some(draft_for(&h.app, None, None));
|
||||
h.frames(16);
|
||||
let description = Some(egui::Id::new("issue_report_body"));
|
||||
click_commands(&mut h, "Continue on GitHub");
|
||||
assert_eq!(h.ctx.memory(|m| m.focused()), description);
|
||||
// Click the Summary field (found by its id: it has no label of its own) and type.
|
||||
let title = egui::Id::new("issue_report_title").accesskit_id();
|
||||
let tree = h.output.accesskit_update.as_ref().unwrap();
|
||||
let b = tree.nodes.iter().find(|(id, _)| *id == title).and_then(|(_, n)| n.bounds()).unwrap();
|
||||
h.step(&json!({"click":[(b.x0 + b.x1) / 2.0, (b.y0 + b.y1) / 2.0]})).unwrap();
|
||||
h.step(&json!({"text":"My title"})).unwrap();
|
||||
h.frames(4);
|
||||
let draft = h.app.issue_report.draft.as_ref().unwrap();
|
||||
assert_eq!((draft.title.as_str(), draft.description.as_str()), ("My title", ""));
|
||||
assert!(draft.missing_description && h.widget("Describe what happened before continuing.").is_some());
|
||||
// Still empty: the next Continue gives it the focus again.
|
||||
click_commands(&mut h, "Continue on GitHub");
|
||||
assert_eq!(h.ctx.memory(|m| m.focused()), description);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_report_handoff_includes_edits_from_the_click_frame() {
|
||||
for field in ["issue_report_body", "issue_report_title", "issue_report_steps", "issue_report_expected", "issue_report_technical"] {
|
||||
|
||||
@@ -153,7 +153,7 @@ pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -
|
||||
draft.opened_github = false;
|
||||
}
|
||||
crate::scenario::publish_rect("report:description", response.rect);
|
||||
if !draft.focus_requested || draft.missing_description {
|
||||
if !draft.focus_requested {
|
||||
response.scroll_to_me(Some(egui::Align::Center));
|
||||
response.request_focus();
|
||||
draft.focus_requested = true;
|
||||
@@ -217,5 +217,10 @@ pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// Found empty, the description takes the focus once more, not every frame: the other
|
||||
// fields stay free to type in (#7190).
|
||||
if action == ui_kit::Action::Ok && draft.missing_description {
|
||||
draft.focus_requested = false;
|
||||
}
|
||||
(retake, closed || action == ui_kit::Action::Cancel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user