File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed
packages/calcite-components/src/components/color-picker Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -2299,5 +2299,31 @@ describe("calcite-color-picker", () => {
2299
2299
expect ( await colorPicker . getProperty ( "value" ) ) . not . toBe ( value ) ;
2300
2300
} ) ;
2301
2301
} ) ;
2302
+
2303
+ describe ( "alpha channel" , ( ) => {
2304
+ it ( "allows editing alpha value via keyboard" , async ( ) => {
2305
+ const page = await newE2EPage ( ) ;
2306
+ await page . setContent ( `<calcite-color-picker alpha-channel value="#ffffffff"></calcite-color-picker>` ) ;
2307
+
2308
+ const picker = await page . find ( "calcite-color-picker" ) ;
2309
+ const scope = await page . find ( `calcite-color-picker >>> .${ CSS . opacityScope } ` ) ;
2310
+
2311
+ await scope . press ( "ArrowDown" ) ;
2312
+ expect ( await picker . getProperty ( "value" ) ) . toBe ( "#fffffffc" ) ;
2313
+ await scope . press ( "ArrowDown" ) ;
2314
+ expect ( await picker . getProperty ( "value" ) ) . toBe ( "#fffffffa" ) ;
2315
+ await scope . press ( "ArrowDown" ) ;
2316
+ expect ( await picker . getProperty ( "value" ) ) . toBe ( "#fffffff7" ) ;
2317
+
2318
+ await scope . press ( "ArrowUp" ) ;
2319
+ expect ( await picker . getProperty ( "value" ) ) . toBe ( "#fffffffa" ) ;
2320
+
2321
+ await scope . press ( "ArrowRight" ) ;
2322
+ expect ( await picker . getProperty ( "value" ) ) . toBe ( "#fffffffc" ) ;
2323
+
2324
+ await scope . press ( "ArrowLeft" ) ;
2325
+ expect ( await picker . getProperty ( "value" ) ) . toBe ( "#fffffffa" ) ;
2326
+ } ) ;
2327
+ } ) ;
2302
2328
} ) ;
2303
2329
} ) ;
Original file line number Diff line number Diff line change @@ -1581,16 +1581,18 @@ export class ColorPicker
1581
1581
const modifier = event . shiftKey ? 10 : 1 ;
1582
1582
const { key } = event ;
1583
1583
const arrowKeyToXOffset = {
1584
- ArrowUp : 1 ,
1585
- ArrowRight : 1 ,
1586
- ArrowDown : - 1 ,
1587
- ArrowLeft : - 1 ,
1584
+ ArrowUp : 0.01 ,
1585
+ ArrowRight : 0.01 ,
1586
+ ArrowDown : - 0.01 ,
1587
+ ArrowLeft : - 0.01 ,
1588
1588
} ;
1589
1589
1590
1590
if ( arrowKeyToXOffset [ key ] ) {
1591
1591
event . preventDefault ( ) ;
1592
- const delta = opacityToAlpha ( arrowKeyToXOffset [ key ] * modifier ) ;
1593
- this . captureHueSliderColor ( this . opacityScopeLeft + delta ) ;
1592
+ const delta = arrowKeyToXOffset [ key ] * modifier ;
1593
+ const alpha = this . baseColorFieldColor . alpha ( ) ;
1594
+ const color = this . baseColorFieldColor . alpha ( alpha + delta ) ;
1595
+ this . internalColorSet ( color , false ) ;
1594
1596
}
1595
1597
} ;
1596
1598
You can’t perform that action at this time.
0 commit comments