From 2b377d8605a35a1fe5abb14c6824ac2e031405b5 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 7 May 2024 10:01:44 +0300 Subject: [PATCH] UI: Fixed paste hex color with prefix --- .../app/shared/components/color-picker/hex-input.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/shared/components/color-picker/hex-input.component.ts b/ui-ngx/src/app/shared/components/color-picker/hex-input.component.ts index fcd91a2397..9d65cf02a6 100644 --- a/ui-ngx/src/app/shared/components/color-picker/hex-input.component.ts +++ b/ui-ngx/src/app/shared/components/color-picker/hex-input.component.ts @@ -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); }