Browse Source

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

Fixed paste hex color with prefix
pull/10787/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
875a737ecf
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      ui-ngx/src/app/shared/components/color-picker/hex-input.component.ts

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

Loading…
Cancel
Save