Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Do not scroll to save button when typing in textarea / input.
N-Shar-ma30b68214d3ce
diff --git a/web/src/settings_components.ts b/web/src/settings_components.tsindex fd11a283bf7..2b51860d5d7 100644--- a/web/src/settings_components.ts+++ b/web/src/settings_components.ts@@ -531,12 +531,20 @@ export function change_save_button_state($element: JQuery, state: string): voidassert(data_status !== undefined);$saveBtn.attr("data-status", data_status);if (state === "unsaved") {- // Ensure the save button is visible when the state is "unsaved",- // so the user does not miss saving their changes.- scroll_util.scroll_element_into_container(- $element.parent(".subsection-header"),- $("#settings_content"),- );+ // Do not scroll if the currently focused element is a textarea or an input+ // of type text, to not interrupt the user's typing flow. Scrolling will happen+ // anyway when the field loses focus (via the change event) if necessary.+ if (+ !document.activeElement ||+ !$(document.activeElement).is('textarea, input[type="text"]')+ ) {+ // Ensure the save button is visible when the state is "unsaved",+ // so the user does not miss saving their changes.+ scroll_util.scroll_element_into_container(+ $element.parent(".subsection-header"),+ $("#settings_content"),+ );+ }enable_or_disable_save_button($element.closest(".settings-subsection-parent"));}assert(is_show !== undefined);diff --git a/web/tests/settings_org.test.js b/web/tests/settings_org.test.jsindex 24ec4823587..7642d2bc327 100644--- a/web/tests/settings_org.test.js+++ b/web/tests/settings_org.test.js@@ -3,7 +3,7 @@const {strict: assert} = require("assert");const {$t} = require("./lib/i18n");-const {mock_esm, zrequire} = require("./lib/namespace");+const {mock_esm, zrequire, set_global} = require("./lib/namespace");const {run_test, noop} = require("./lib/test");const blueslip = require("./lib/zblueslip");const $ = require("./lib/zjquery");@@ -19,6 +19,7 @@ mock_esm("../src/loading", {destroy_indicator: noop,});mock_esm("../src/scroll_util", {scroll_element_into_container: noop});+set_global("document", "document-stub");const settings_config = zrequire("settings_config");const settings_bots = zrequire("settings_bots");