Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
portico: Inline common.autofocus.
Tim Abbotta379fbe4424c
diff --git a/web/src/common.ts b/web/src/common.tsindex c34b6cc210e..0cd303a7070 100644--- a/web/src/common.ts+++ b/web/src/common.ts@@ -6,13 +6,6 @@ import {$t} from "./i18n";export const status_classes = "alert-error alert-success alert-info alert-warning alert-loading";-// TODO: Move this to the portico codebase.-export function autofocus($elem: JQuery): void {- $(() => {- $elem.trigger("focus");- });-}-export function phrase_match(query: string, phrase: string): boolean {// match "tes" to "test" and "stream test" but not "hostess"let i;diff --git a/web/src/portico/signup.ts b/web/src/portico/signup.tsindex 3675a0c1afb..97d4b634236 100644--- a/web/src/portico/signup.ts+++ b/web/src/portico/signup.ts@@ -74,7 +74,7 @@ $(() => {// not hidden and disabled and store it in a variable.const $firstInputElement = $("input:not(:hidden, :disabled)").first();// Focus on the first input field in the form.- common.autofocus($firstInputElement);+ $firstInputElement.trigger("focus");} else {// If input field with errors is present.// Find the input field having errors and stores it in a variable.@@ -83,7 +83,7 @@ $(() => {.parent().find("input");// Focus on the input field having errors.- common.autofocus($inputElementWithError);+ $inputElementWithError.trigger("focus");}// reset error message displaysdiff --git a/web/tests/common.test.js b/web/tests/common.test.jsindex 6ee70b1b748..326b41f4cb4 100644--- a/web/tests/common.test.js+++ b/web/tests/common.test.js@@ -20,13 +20,6 @@ const navigator = set_global("navigator", {});const common = zrequire("common");-run_test("basics", () => {- common.autofocus($("#home"));- $.get_initialize_function()();- assert.ok($("#home").is_focused());- $.clear_initialize_function();-});-run_test("phrase_match", () => {assert.ok(common.phrase_match("tes", "test"));assert.ok(common.phrase_match("Tes", "test"));