Merge pull request #10729 from ArtemDzhereleiko/AD/imp/paste-hex-with-prefix

Fixed paste hex color with prefix
This commit is contained in:
Igor Kulikov 2024-05-13 16:05:00 +03:00 committed by GitHub
commit 875a737ecf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,14 +59,14 @@ export class HexInputComponent {
}
public onInputChange(event: KeyboardEvent, inputValue: string): void {
const value = inputValue.toLowerCase();
const value = inputValue.replace('#', '').toLowerCase();
if (
((event.keyCode === 13 || event.key.toLowerCase() === 'enter') && value.length === 3)
|| value.length === 6 || value.length === 8
) {
const hex = parseInt(value, 16);
const hexStr = hex.toString(16);
if (hexStr.padStart(value.length, '0') === value && this.value !== value) {
if (hexStr.padStart(value.length, '0') === value && this.value.toLowerCase() !== value) {
const newColor = new Color(`#${value}`);
this.colorChange.emit(newColor);
}