Repository navigation
fix(ui): Linux 原生下拉框不再把选中文字裁成半截 - #109
Merged
std-microblock merged 1 commit intoNov 25, 2026
Merged
Conversation
WebKitGTK 在绘制原生 <select> 时自带内部布局:当定值 height 把内容盒压到 只剩一行文字的高度时,选中项的文字会被裁成中间一条(1.3.1 上所有下拉框都 这样)。下拉框的文字本来就是由 menulist 自己垂直居中的,上下 padding 只会 把内容盒压小,不影响文字位置,所以 Linux 下去掉它:盒子尺寸不变,文字完整。 只在 html[data-platform="linux"] 下生效(Linux 上 Tauri 走 WebKitGTK), Windows / macOS / Android 的渲染与之前在像素级一致。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linux(Tauri 用 WebKitGTK)上所有原生
<select>的选中文字都被纵向裁掉,只剩中间一条,用户从 1.3.1 源码自行编译后报告;首页语言/游戏路径、设置里的下载镜像、搜索/管理页的筛选下拉都一样。成因
WebKitGTK 画原生 menulist 时用自己的内部布局,要求内容盒至少能放下一行文字再加一点余量(本机 WebKitGTK 2.54 实测阈值 ≈ 22px)。CeleMod 的
select规则都是「定值height+ 上下 padding」,内容盒只剩 16~18px:index.scss全局select.home-language select.gameSelector .game-path-field select.settings-page selectselectselect内容盒不够时,内容盒够的那几处(比如搜索筛选,没有上下 padding)就正常——同一份 CSS 里两种表现,可以佐证是内容盒高度的问题,
height写不写死或字体不同都只是外因。Chromium/WebView2/WKWebView 不受影响,所以只有 Linux 用户看到。改动
src/celemod-ui/src/index.scss,一条只在 Linux 生效的覆盖:data-platform由initializeWindowChrome()在启动时写到<html>上(Multiplayer.scss已经在用html[data-platform="android"])。下拉框的文字本来由 menulist 自己垂直居中,上下 padding 只缩小内容盒、不改变文字位置,所以去掉它:盒子尺寸不变,内容盒回到 30px 级别,文字完整显示。!important是因为.gameSelector .game-path-field select这类规则的 specificity 高于它。验证
用
pnpm build产出的真实dist/assets/index-*.css+ 真实 DOM 结构(.home-language/.gameSelector .game-path-field/.settings-page/ 裸select),在本机 WebKitGTK 2.54(libwebkit2gtk-4.1 2.54.0)里截图对比:data-platform="windows"(即改动前的效果):四处下拉文字全被裁成一条,和用户截图一致data-platform="linux"(改动后):四处文字完整,盒子宽高不变(32/40/34/32)data-platform不是linux,这条规则不参与匹配,渲染与改动前一致pnpm build(tsc --noEmit+vite build)通过备注
height换成min-height(内容盒交给引擎撑开),但那样在字体行高较大的系统上盒子会涨 1~3px,密集布局里(管理页筛选行、首页语言按钮)会跟着动,所以我选了只改 padding 的版本。