Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: provide better UX for HTML color picker edit #2942

Merged

Conversation

leon-richardt
Copy link
Collaborator

@leon-richardt leon-richardt commented Jun 30, 2021

Pull request checklist:

  • CHANGELOG.md was updated, if applicable

Description

Fixes #2939. See there and the commit message for additional context.

Original commit message:

Before this change, it was checked whether the text of the HTML color
picker line edit represents a valid color. Since the HTML color syntax
allows the format #RGB (see 1), this lead to the lambda setting the
color edit to the full format string (#RRGGBB) whenever three
characters have been entered.
Due to the QValidator set up for the line edit, attempts to change the
text again would be rejected.

With this change, validity of the color is only checked when the
QLineEdit::editingFinished signal is emitted. (At the time of writing,
this corresponds to "Return" being pressed or a focus loss of the line
edit.) Since the signal is only emitted when the validator approves the
input (see 2 for more information), this will never lead to the color
picker being in an inconsistent state.

Before this change, it was checked whether the text of the HTML color
picker line edit represents a valid color. Since the HTML color syntax
allows the format `#RGB` (see [1]), this lead to the lambda setting the
color edit to the full format string (`#RRGGBB`) whenever three
characters have been entered.
Due to the QValidator set up for the line edit, attempts to change the
text again would be rejected.

With this change, validity of the color is only checked when the
`QLineEdit::editingFinished` signal is emitted. (At the time of writing,
this corresponds to "Return" being pressed or a focus loss of the line
edit.) Since the signal is only emitted when the validator approves the
input (see [2] for more information), this will never lead to the color
picker being in an inconsistent state.

[1]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#syntax_2
[2]: https://doc.qt.io/qt-5/qlineedit.html#editingFinished
@Mm2PL Mm2PL self-requested a review June 30, 2021 19:02
@zneix zneix merged commit 0dd545f into Chatterino:master Jul 2, 2021
zneix added a commit to SevenTV/chatterino7 that referenced this pull request Jul 5, 2021
Now we're on commit cc9d44a; Changes from upstream we pulled:

- Minor: Username in channel points rewards redemption messages is now clickable. (Chatterino#2673, Chatterino#2953)
- Bugfix: Now deleting cache files that weren't modified in the past 14 days. (Chatterino#2947)
- Bugfix: Middle mouse click no longer scrolls in not fully populated usercards and splits. (Chatterino#2933)
- Bugfix: Fix bad behavior of the HTML color picker edit when user input is being entered. (Chatterino#2942)
@leon-richardt leon-richardt deleted the fix/html-color-input-validation branch October 14, 2021 12:16
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.

Color picker HTML field weirdness
3 participants