Skip to content

Fix: accept a hex color typed without its leading hash - #132

Merged
SandObserver merged 1 commit into
mainfrom
fix/color-field-missing-hash
Aug 20, 2026
Merged

SandObserver merged 1 commit into
mainfrom
fix/color-field-missing-hash

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Parse a CSS color with two seeded fillStyle reads, so _cssToHex returns null for an unparseable value instead of the seeded black.
  • Add normalizeColorInput, which supplies a missing leading # for a bare 3 to 8 digit hex code and reports whether the value parses at all.
  • Use it in the color control's code row and in the appearance background color field, and show a toast when the value is not a color.
  • Add toast.colorInvalid to all six catalogs.

Testing
All green. Added 5 frontend tests for the parser and the normaliser, and updated the case that pinned black for an unreadable value.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.
  • CHANGELOG.md updated under Unreleased if the change is user-visible.

Detect an invalid CSS color with two seeded fillStyle reads, so an
unparseable value no longer resolves to black. Add the leading hash to a
bare 3 to 8 digit hex code in the color control and in the background
color field, and warn when a value is not a color.
@SandObserver SandObserver added the bug Something isn't working label Aug 20, 2026
@SandObserver
SandObserver merged commit 82f52ce into main Aug 20, 2026
4 checks passed
@SandObserver
SandObserver deleted the fix/color-field-missing-hash branch August 20, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant