From d464d625d84156354ecf84910b55b8a65488e0e8 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 27 Jun 2026 23:30:59 +0200 Subject: [PATCH] feat: Move repo topic selector to tom-select (#12736) This is a proof of concept for replacing Formatic's buggy dropdown with something else. There are a bunch of open gitea issues on github discussing getting rid of Fomantic. Tested in Firefox/Chrome. Attached screenshots are before/after. The one with the input focused in orange, and tighter letter spacing, is after. If this is merged I plan to move the other selectors off of Fomantic. Alternative to https://codeberg.org/forgejo/forgejo/pulls/12731, also fixes #10118 Signed-off-by: Markus Unterwaditzer Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12736 Reviewed-by: Gusted --- package-lock.json | 33 ++++++ package.json | 1 + routers/web/repo/view.go | 7 +- templates/repo/home.tmpl | 11 +- web_src/css/features/tom-select.css | 120 ++++++++++++++++++++ web_src/css/index.css | 1 + web_src/js/features/repo-home.js | 165 +++++++++++++--------------- web_src/js/modules/tom-select.ts | 34 ++++++ 8 files changed, 276 insertions(+), 96 deletions(-) create mode 100644 web_src/css/features/tom-select.css create mode 100644 web_src/js/modules/tom-select.ts diff --git a/package-lock.json b/package-lock.json index bb4f7715d8..a3112d347a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,6 +71,7 @@ "tinycolor2": "1.6.0", "tippy.js": "6.3.7", "toastify-js": "1.12.0", + "tom-select": "2.4.3", "tributejs": "5.1.3", "uint8-to-base64": "0.2.1", "vanilla-colorful": "0.7.2", @@ -2915,6 +2916,21 @@ "dev": true, "license": "MIT" }, + "node_modules/@orchidjs/sifter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@orchidjs/sifter/-/sifter-1.1.0.tgz", + "integrity": "sha512-mYwHCfr736cIWWdhhSZvDbf90AKt2xyrJspKFC3qyIJG1LtrJeJunYEqCGG4Aq2ijENbc4WkOjszcvNaIAS/pQ==", + "license": "Apache-2.0", + "dependencies": { + "@orchidjs/unicode-variants": "^1.1.2" + } + }, + "node_modules/@orchidjs/unicode-variants": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@orchidjs/unicode-variants/-/unicode-variants-1.1.2.tgz", + "integrity": "sha512-5DobW1CHgnBROOEpFlEXytED5OosEWESFvg/VYmH0143oXcijYTprRYJTs+55HzGM4IqxiLFSuqEzu9mPNwVsA==", + "license": "Apache-2.0" + }, "node_modules/@oxc-project/types": { "version": "0.133.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.133.0.tgz", @@ -15448,6 +15464,23 @@ "integrity": "sha512-HeMHCO9yLPvP9k0apGSdPUWrUbLnxUKNFzgUoZp1PHCLploIX/4DSQ7V8H25ef+h4iO9n0he7ImfcndnN6nDrQ==", "license": "MIT" }, + "node_modules/tom-select": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tom-select/-/tom-select-2.4.3.tgz", + "integrity": "sha512-MFFrMxP1bpnAMPbdvPCZk0KwYxLqhYZso39torcdoefeV/NThNyDu8dV96/INJ5XQVTL3O55+GqQ78Pkj5oCfw==", + "license": "Apache-2.0", + "dependencies": { + "@orchidjs/sifter": "^1.1.0", + "@orchidjs/unicode-variants": "^1.1.2" + }, + "engines": { + "node": "*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/tom-select" + } + }, "node_modules/toml-eslint-parser": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/toml-eslint-parser/-/toml-eslint-parser-0.12.0.tgz", diff --git a/package.json b/package.json index 596d977a3b..ecf2dbbcae 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "tinycolor2": "1.6.0", "tippy.js": "6.3.7", "toastify-js": "1.12.0", + "tom-select": "2.4.3", "tributejs": "5.1.3", "uint8-to-base64": "0.2.1", "vanilla-colorful": "0.7.2", diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 09adfae069..8dfbcf10e1 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -954,7 +954,12 @@ func renderRepoTopics(ctx *context.Context) { ctx.ServerError("models.FindTopics", err) return } - ctx.Data["Topics"] = topics + + topicNames := make([]string, 0, len(topics)) + for _, t := range topics { + topicNames = append(topicNames, t.Name) + } + ctx.Data["Topics"] = topicNames } func prepareOpenWithEditorApps(ctx *context.Context) { diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 3f82f79c69..c3e626c95f 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -13,7 +13,7 @@
{{range .Topics}} - {{.Name}} + {{.}} {{end}} {{if and .Permission.IsAdmin (not .Repository.IsArchived)}} @@ -22,13 +22,8 @@ {{end}} {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
-