Ribbon tab clicks no longer scroll the page to the caret while a footer is edited (#2054) (#2121)

This commit is contained in:
MarekSpodBiedry
2026-10-18 04:00:18 -04:00
committed by GitHub
parent 1cc3d190a7
commit ecd94e0f8a
+12 -1
View File
@@ -1194,7 +1194,7 @@ impl WordApp {
// Drawing leaves the caret where it was: following it would pull the view off the ink.
if self.session.selects_whole_story() || id == "select.all" {
self.canvas.scroll_to_caret = false;
} else if !id.starts_with("view.") && !id.starts_with("document.") && !id.starts_with("format.state") && !id.starts_with("draw.") {
} else if !["ui.", "view.", "document.", "format.state", "draw."].iter().any(|p| id.starts_with(p)) {
self.canvas.scroll_to_caret = true;
}
for req in std::mem::take(&mut self.session.ui_requests) {
@@ -6728,6 +6728,17 @@ mod tests {
assert!(a.canvas.scroll_to_caret, "typing still brings the caret into view");
}
/// #2054: clicking a ribbon tab while a footer is being edited scrolled the page a little.
#[test]
fn ribbon_tab_click_does_not_follow_the_caret() {
let mut a = typed();
a.canvas.scroll_to_caret = false;
a.run("ui.tab", json!({"tab": "Design"})).unwrap();
assert!(!a.canvas.scroll_to_caret, "switching tabs left the view alone");
a.run("text.insert", json!({"text": "x"})).unwrap();
assert!(a.canvas.scroll_to_caret, "typing still brings the caret into view");
}
#[test]
fn select_all_does_not_scroll_to_the_end() {
let mut a = typed();