From faed93370f0982972b55aefb32a2949123188dd9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 21 Mar 2024 11:16:11 +0100 Subject: [PATCH] Fix JS error and improve error message styles (#29963) Fixes: https://github.com/go-gitea/gitea/issues/29956. This error exposed a existing bug in the code, it was just never noticed because the jQuery expression evaluated without error before while the new one doesn't. Also improves error message styles: Before: Screenshot 2024-03-21 at 09 16 07 After: Screenshot 2024-03-21 at 09 15 44 (cherry picked from commit 1a4f693f9f9723c181b747cb6d658aa37118005a) --- web_src/js/bootstrap.js | 2 +- web_src/js/features/repo-common.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/web_src/js/bootstrap.js b/web_src/js/bootstrap.js index 698d17fa36..3034478190 100644 --- a/web_src/js/bootstrap.js +++ b/web_src/js/bootstrap.js @@ -23,7 +23,7 @@ export function showGlobalErrorMessage(msg) { let msgDiv = pageContent.querySelector(`.js-global-error[data-global-error-msg-compact="${msgCompact}"]`); if (!msgDiv) { const el = document.createElement('div'); - el.innerHTML = `
`; + el.innerHTML = `
`; msgDiv = el.childNodes[0]; } // merge duplicated messages into "the message (count)" format diff --git a/web_src/js/features/repo-common.js b/web_src/js/features/repo-common.js index 9e11ffe197..669b47a9c5 100644 --- a/web_src/js/features/repo-common.js +++ b/web_src/js/features/repo-common.js @@ -76,6 +76,8 @@ export function initRepoCommonBranchOrTagDropdown(selector) { export function initRepoCommonFilterSearchDropdown(selector) { const $dropdown = $(selector); + if (!$dropdown.length) return; + $dropdown.dropdown({ fullTextSearch: 'exact', selectOnKeydown: false,