@@ -87,6 +87,20 @@ const metadata = {
87
87
defaultValue : 0 ,
88
88
} ,
89
89
90
+ /**
91
+ * @private
92
+ */
93
+ _isSelectedColorChanged : {
94
+ type : Boolean ,
95
+ } ,
96
+
97
+ /**
98
+ * @private
99
+ */
100
+ _isHueValueChanged : {
101
+ type : Boolean ,
102
+ } ,
103
+
90
104
/**
91
105
* @private
92
106
*/
@@ -326,6 +340,8 @@ class ColorPicker extends UI5Element {
326
340
this . selectedHue = event . target . value ;
327
341
this . _hue = this . selectedHue ;
328
342
this . _setMainColor ( this . _hue ) ;
343
+ // Idication that changes to the hue value triggered as a result of user pressing over the hue slider.
344
+ this . _isHueValueChanged = true ;
329
345
330
346
const tempColor = this . _calculateColorFromCoordinates ( this . _selectedCoordinates . x + 6.5 , this . _selectedCoordinates . y + 6.5 ) ;
331
347
@@ -425,6 +441,9 @@ class ColorPicker extends UI5Element {
425
441
y : y - 6.5 , // Center the coordinates, because of the height of the circle
426
442
} ;
427
443
444
+ // Idication that changes to the color settings are triggered as a result of user pressing over the main color section.
445
+ this . _isSelectedColorChanged = true ;
446
+
428
447
const tempColor = this . _calculateColorFromCoordinates ( x , y ) ;
429
448
if ( tempColor ) {
430
449
this . _setColor ( HSLToRGB ( tempColor ) ) ;
@@ -435,7 +454,7 @@ class ColorPicker extends UI5Element {
435
454
// By using the selected coordinates(x = Lightness, y = Saturation) and hue(selected from the hue slider)
436
455
// and HSL format, the color will be parsed to RGB
437
456
438
- const h = Math . round ( this . _hue / 4.25 ) , // 0 ≤ H < 360
457
+ const h = this . _hue / 4.25 , // 0 ≤ H < 360
439
458
// 0 ≤ S ≤ 1
440
459
s = 1 - + ( Math . round ( ( y / 256 ) + "e+2" ) + "e-2" ) , // eslint-disable-line
441
460
// 0 ≤ V ≤ 1
@@ -488,7 +507,15 @@ class ColorPicker extends UI5Element {
488
507
y : ( 256 - ( Math . round ( hslColours . s * 100 ) * 2.56 ) ) - 6.5 , // Center the coordinates, because of the height of the circle
489
508
} ;
490
509
491
- this . _hue = this . selectedHue ? this . selectedHue : Math . round ( hslColours . h * 4.25 ) ;
510
+ if ( this . _isSelectedColorChanged ) { // We shouldn't update the hue value when user presses over the main color section.
511
+ this . _isSelectedColorChanged = false ;
512
+ } else if ( this . _isHueValueChanged ) { // We shouldn't recalculate the hue value when user changes the hue slider.
513
+ this . _isHueValueChanged = false ;
514
+ this . _hue = this . selectedHue ? this . selectedHue : this . _hue ;
515
+ } else {
516
+ this . _hue = Math . round ( hslColours . h * 4.25 ) ;
517
+ }
518
+
492
519
this . _setMainColor ( this . _hue ) ;
493
520
}
494
521
0 commit comments