mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +00:00
LibGUI: Don't allow 4 character html color codes in GUI::ColorPicker
When 4 character colors were allowed, backspace misbehaved and you couldn't backspace the whole color.
This commit is contained in:
parent
d89cad7c57
commit
9670d9ad50
Notes:
sideshowbarker
2024-07-19 02:22:22 +09:00
Author: https://github.com/petelliott
Commit: 9670d9ad50
Pull-request: https://github.com/SerenityOS/serenity/pull/3517
Issue: https://github.com/SerenityOS/serenity/issues/3406
1 changed files with 3 additions and 1 deletions
|
@ -292,7 +292,9 @@ void ColorPicker::build_ui_custom(Widget& root_container)
|
|||
m_html_text->on_change = [this]() {
|
||||
auto color_name = m_html_text->text();
|
||||
auto optional_color = Color::from_string(color_name);
|
||||
if (optional_color.has_value()) {
|
||||
if (optional_color.has_value() && (!color_name.starts_with("#") || color_name.length() == ((m_color_has_alpha_channel) ? 9 : 7))) {
|
||||
// The color length must be 9/7 (unless it is a name like red), because:
|
||||
// - If we allowed 5/4 character rgb color, the field would reset to 9/7 characters after you deleted 4/3 characters.
|
||||
auto color = optional_color.value();
|
||||
if (m_color == color)
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue