Merge pull request #10729 from ArtemDzhereleiko/AD/imp/paste-hex-with-prefix
Fixed paste hex color with prefix
This commit is contained in:
		
						commit
						875a737ecf
					
				@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user