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:
<img width="1338" alt="Screenshot 2024-03-21 at 09 16 07"
src="https://github.com/go-gitea/gitea/assets/115237/1cc1ef89-ad94-491e-bbca-75387f7547a0">

After:
<img width="1335" alt="Screenshot 2024-03-21 at 09 15 44"
src="https://github.com/go-gitea/gitea/assets/115237/312efc79-5353-4e2a-a703-1bccd3c01736">
This commit is contained in:
silverwind 2024-03-21 11:16:11 +01:00 committed by GitHub
parent 82db9a2ba7
commit 1a4f693f9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -23,7 +23,7 @@ export function showGlobalErrorMessage(msg) {
let msgDiv = pageContent.querySelector(`.js-global-error[data-global-error-msg-compact="${msgCompact}"]`); let msgDiv = pageContent.querySelector(`.js-global-error[data-global-error-msg-compact="${msgCompact}"]`);
if (!msgDiv) { if (!msgDiv) {
const el = document.createElement('div'); const el = document.createElement('div');
el.innerHTML = `<div class="ui container negative message center aligned js-global-error" style="white-space: pre-line;"></div>`; el.innerHTML = `<div class="ui container negative message center aligned js-global-error tw-mt-[15px] tw-whitespace-pre-line"></div>`;
msgDiv = el.childNodes[0]; msgDiv = el.childNodes[0];
} }
// merge duplicated messages into "the message (count)" format // merge duplicated messages into "the message (count)" format

View File

@ -76,6 +76,8 @@ export function initRepoCommonBranchOrTagDropdown(selector) {
export function initRepoCommonFilterSearchDropdown(selector) { export function initRepoCommonFilterSearchDropdown(selector) {
const $dropdown = $(selector); const $dropdown = $(selector);
if (!$dropdown.length) return;
$dropdown.dropdown({ $dropdown.dropdown({
fullTextSearch: 'exact', fullTextSearch: 'exact',
selectOnKeydown: false, selectOnKeydown: false,