From e6c17f31be3da2196a0311f22adb2afe7c175176 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 6 Apr 2025 12:25:29 +0000 Subject: [PATCH] fix(ui): only run auth_name code on new and edit page (#7470) - Only run the dynamic `auth_name` update code when its on the new or edit page. `.admin.authentication` also matches the main authentication screen which lead to a javascript error. - Regression of forgejo/forgejo#7408 # Testing 1. Login as a admin. 2. Go to `/admin/auths`. 3. Notice no errors. 4. Go to `admin/auths/new`. 6. Select 'OAuth2' as authentication type. 5. Type some input into the 'Authentication name'. 6. Notice the the callback URL in the 'Tips' section including the authentication name. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7470 Reviewed-by: Michael Kriese Co-authored-by: Gusted Co-committed-by: Gusted --- web_src/js/features/admin/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js index b46f4f8a74..76cf4e57f7 100644 --- a/web_src/js/features/admin/common.js +++ b/web_src/js/features/admin/common.js @@ -199,7 +199,7 @@ export function initAdminCommon() { } } - if (document.querySelector('.admin.authentication')) { + if (document.querySelector('.admin.edit.authentication, .admin.new.authentication')) { const authNameEl = document.getElementById('auth_name'); authNameEl.addEventListener('input', (el) => { // appSubUrl is either empty or is a path that starts with `/` and doesn't have a trailing slash.