Skip to content

Commit 0179c6a

Browse files
committed
fix(adobe#1118): Color Area more unit tests
1 parent 2b5e368 commit 0179c6a

File tree

3 files changed

+287
-42
lines changed

3 files changed

+287
-42
lines changed

packages/@react-aria/color/src/useColorArea.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function useColorArea(props: ColorAreaAriaProps, state: ColorAreaState, i
9191
let focusedInputRef = useRef<HTMLElement>(null);
9292

9393
let focusInput = useCallback((inputRef = inputXRef) => {
94-
if (inputRef) {
94+
if (inputRef.current) {
9595
focusWithoutScrolling(inputRef.current);
9696
}
9797
}, [inputXRef]);
@@ -112,13 +112,13 @@ export function useColorArea(props: ColorAreaAriaProps, state: ColorAreaState, i
112112
if (!e.shiftKey && /^Arrow(?:Right|Left|Up|Down)$/.test(e.key)) {
113113
return;
114114
}
115-
let stepSize = CHANNEL_STEP_SIZE[xChannel];
115+
let stepSize = Math.max(step, CHANNEL_STEP_SIZE[xChannel]);
116116
let range = stateRef.current.value.getChannelRange(xChannel);
117117
switch (e.key) {
118118
case 'PageUp':
119119
case 'ArrowUp':
120120
range = stateRef.current.value.getChannelRange(yChannel);
121-
stepSize = CHANNEL_STEP_SIZE[yChannel];
121+
stepSize = Math.max(step, CHANNEL_STEP_SIZE[yChannel]);
122122
stateRef.current.setYValue(
123123
clamp(
124124
(Math.floor(stateRef.current.yValue / stepSize) + 1) * stepSize,
@@ -131,7 +131,7 @@ export function useColorArea(props: ColorAreaAriaProps, state: ColorAreaState, i
131131
case 'PageDown':
132132
case 'ArrowDown':
133133
range = stateRef.current.value.getChannelRange(yChannel);
134-
stepSize = CHANNEL_STEP_SIZE[yChannel];
134+
stepSize = Math.max(step, CHANNEL_STEP_SIZE[yChannel]);
135135
stateRef.current.setYValue(
136136
clamp(
137137
(Math.ceil(stateRef.current.yValue / stepSize) - 1) * stepSize,
@@ -527,7 +527,7 @@ export function useColorArea(props: ColorAreaAriaProps, state: ColorAreaState, i
527527
style: HIDDEN_INPUT_STYLES,
528528
title: getValueTitle(),
529529
disabled: isDisabled,
530-
value: `${state.value.getChannelValue(xChannel)}`,
530+
value: state.value.getChannelValue(xChannel),
531531
tabIndex: 0,
532532
onChange: (e: ChangeEvent<HTMLInputElement>) => {
533533
state.setXValue(parseFloat(e.target.value));
@@ -552,7 +552,7 @@ export function useColorArea(props: ColorAreaAriaProps, state: ColorAreaState, i
552552
},
553553
title: getValueTitle(),
554554
disabled: isDisabled,
555-
value: `${state.value.getChannelValue(yChannel)}`,
555+
value: state.value.getChannelValue(yChannel),
556556
tabIndex: -1,
557557
onChange: (e: ChangeEvent<HTMLInputElement>) => {
558558
state.setYValue(parseFloat(e.target.value));

0 commit comments

Comments
 (0)