diff --git a/web/src/common.ts b/web/src/common.ts index b595513594..c34b6cc210 100644 --- a/web/src/common.ts +++ b/web/src/common.ts @@ -7,9 +7,9 @@ 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(selector: string): void { +export function autofocus($elem: JQuery): void { $(() => { - $(selector).trigger("focus"); + $elem.trigger("focus"); }); } diff --git a/web/tests/common.test.js b/web/tests/common.test.js index e65999a30e..6ee70b1b74 100644 --- a/web/tests/common.test.js +++ b/web/tests/common.test.js @@ -21,7 +21,7 @@ const navigator = set_global("navigator", {}); const common = zrequire("common"); run_test("basics", () => { - common.autofocus("#home"); + common.autofocus($("#home")); $.get_initialize_function()(); assert.ok($("#home").is_focused()); $.clear_initialize_function();