UI: Fixed paste hex color with prefix

This commit is contained in:
Artem Dzhereleiko 2024-05-07 10:01:44 +03:00
parent dd9d9a8a54
commit 2b377d8605

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);
}