-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] ColorPicker: Convert custom string to valid HEX color
When defining a custom color, a user can input pretty much any string, the validity of the said string will only be checked when he will try to add the custom value. More specifically, a user can input a hex value without its prefix `#` (e.g. `eeeaaa` instead of `#eeeaaa`). Such value is interpreted in css but not by the canvas context. Trying to set the `fillColor` to a hex value without the prefix will simply fail. ```javascript const canvas = document.querySelector('canvas') const ctx = canvas.getContext('2d') ctx.fillColor = "#FFF" console.log(ctx.fillColor) // "#FFF" ctx.fillColor = "eeeaaa" console.log(ctx.fillColor) // "#FFF" ctx.fillColor = "#eeeaaa" console.log(ctx.fillColor) // "#eeeaaa" ``` This commit ensures that we convert the user input to a proper HEX representation before invoking the `onColorPicked` callback. closes #2214 Task: 3224839 X-original-commit: 0c4f643 Signed-off-by: Pierre Rousseau (pro) <[email protected]> Signed-off-by: Rémi Rahir (rar) <[email protected]>
- Loading branch information
Showing
3 changed files
with
27 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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