Skip to content

Allow localized color picker validation messages - #60

Closed
mirakyux wants to merge 2 commits into
Lithe-IDEA:mainfrom
mirakyux:fix/color-picker-invalid-label
Closed

mirakyux wants to merge 2 commits into
Lithe-IDEA:mainfrom
mirakyux:fix/color-picker-invalid-label

Conversation

@mirakyux

@mirakyux mirakyux commented Nov 25, 2026 •

Copy link
Copy Markdown

What this changes

Add ColorPickerLabels.InvalidColor so applications can pass a localized message through PanelLabels. The picker continues to show Invalid color when the caller leaves the field empty.

Why

The color picker already accepts translated labels and button text. Its invalid HEX message came from a fixed English string in the UI painter.

How it was verified

  • All tracked Go files pass gofmt -l.
  • go vet ./... on Windows amd64.
  • go test ./ui ./base ./components -count=1 -timeout=60s -run 'ColorPicker|OpenAlphaColorPicker'.
  • go test ./... -count=1 -timeout=120s on Windows amd64. The UI and component packages passed. The full run reported a packaging test timeout and failures in the packaging and documentation tools.

Visual evidence

  • Open a picker with PanelLabels(ColorPickerLabels{InvalidColor: "无效的十六进制颜色"}) and type an invalid HEX value. The panel displays the supplied message and leaves the staged color unapplied.
  • The downstream Windows amd64 headless regression TestEditorRainbowPaletteShowsLocalizedInvalidHex covers the Chinese message and verifies that Enter leaves the color unchanged.

Where the boundary sits

Viva owns the validation and renders the message through its existing error field. Applications supply the text for their locale.

Cost

The existing invalid-input branch reads the optional label and uses the default when it is empty. The focused suite includes the warm picker allocation checks.

Review follow-up

Current fork CI status: the two workflows for d8c0a63 require maintainer approval (action_required). The API approval attempt returned HTTP 403 (Must have admin rights to Repository); no workflow restriction was bypassed. Local ColorPicker tests and race results above remain valid.

上游范围更正:原 vivaui#457 错误包含 fork 历史,已关闭。替代 PR vivaui#458 从上游 main 创建,仅 1 个提交、3 个文件(+41/-1),只含 InvalidColor 文案修复和回归测试。fork #60 的分支与内容保留。

@xiaoyumuxi

xiaoyumuxi commented Nov 25, 2026 •

Copy link
Copy Markdown

@mirakyux 记得给上游 viva 提交一下

@xiaoyumuxi

Copy link
Copy Markdown

@mirakyux 这个改动只能留在 Viva 里。“Invalid color”这句文案写死在 ui/color_paint.go 的 paintColorPickerPanel 里,应用层没有任何钩子能改到它,Lithe 没办法自己翻译。所以方向没问题,再补两点就可以合入:

  1. 加测试:设置了 Labels.InvalidColor 时,输入非法 Hex 后面板显示传入的文案;没设置时仍然显示 Invalid color。
  2. 向上游提 PR:按仓库规则,用同一个分支向 vivaui/viva 提 PR(xiaoyumuxi 上面也提醒过),然后把上游 PR 链接贴回这里。

合入 fork main 后,Lithe 的 desktop/go.mod 中 replace 固定的版本由维护者来升级。在那之前,1lck/Lithe-IDEA#2420 会一直编译不过。

@mirakyux

Copy link
Copy Markdown
Author

已补齐自定义错误文案/默认英文的无头回归测试,并确认自定义文案场景在原 painter 上失败、修复后通过;ColorPicker 全部定向测试及 -race 通过。

同一分支已向上游提交 Draft PR:vivaui#457

Lithe 宿主 #2420 保持 Draft,等 fork 合入后由维护者升级固定 Viva 版本。

@mirakyux

Copy link
Copy Markdown
Author

已补齐自定义错误文案/默认英文的无头回归测试,并确认自定义文案场景在原 painter 上失败、修复后通过;ColorPicker 全部定向测试及 -race 通过。

同一分支已向上游提交 Draft PR:vivaui#457

Lithe 宿主 #2420 保持 Draft,等 fork 合入后由维护者升级固定 Viva 版本。

上游已完成合并 : vivaui#458

@xiaoyumuxi

Copy link
Copy Markdown

这次同步(#63,fork main 7696355e)已经带进上游 b5876fcb(vivaui#458)。它和本 PR 的改动逐行相同(base/state_types.go、ui/color_paint.go、ui/color_test.go,+41/−1),所以按 fork 规则以“已被上游取代”关闭,不再单独合入。

1lck/Lithe-IDEA#2420 需要的 ColorPickerLabels.InvalidColor 现在已经在 fork main 里,Lithe 的固定版本由维护者在单独的 PR 里升级。谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants