Skip to content

Commit fff7f7e

Browse files
committed
handle to actions
1 parent b9017d5 commit fff7f7e

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/InputNumber.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const getDecimalIfValidate = (value: ValueType) => {
5454
return decimal.isInvalidate() ? null : decimal;
5555
};
5656

57-
type SemanticName = 'handle' | 'input';
57+
type SemanticName = 'actions' | 'input';
5858
export interface InputNumberProps<T extends ValueType = ValueType>
5959
extends Omit<
6060
React.InputHTMLAttributes<HTMLInputElement>,
@@ -619,7 +619,10 @@ const InternalInputNumber = React.forwardRef(
619619
onStep={onInternalStep}
620620
/>
621621
)}
622-
<div className={clsx(`${inputClassName}-wrap`, classNames?.handle)} style={styles?.handle}>
622+
<div
623+
className={clsx(`${inputClassName}-wrap`, classNames?.actions)}
624+
style={styles?.actions}
625+
>
623626
<input
624627
autoComplete="off"
625628
role="spinbutton"
@@ -673,9 +676,9 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
673676
nativeElement: holderRef.current.nativeElement || inputNumberDomRef.current,
674677
}),
675678
);
676-
679+
const memoizedValue = React.useMemo(() => ({ classNames, styles }), [classNames, styles]);
677680
return (
678-
<SemanticContext.Provider value={{ classNames, styles }}>
681+
<SemanticContext.Provider value={memoizedValue}>
679682
<BaseInput
680683
className={className}
681684
triggerFocus={focus}

src/StepHandler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default function StepHandler({
100100
};
101101

102102
return (
103-
<div className={cls(`${handlerClassName}-wrap`, classNames?.handle)} style={styles?.handle}>
103+
<div className={cls(`${handlerClassName}-wrap`, classNames?.actions)} style={styles?.actions}>
104104
<span
105105
{...sharedHandlerProps}
106106
onMouseDown={(e) => {

tests/semantic.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ describe('InputNumber.Semantic', () => {
88
prefix: 'test-prefix',
99
input: 'test-input',
1010
suffix: 'test-suffix',
11-
handle: 'test-handle',
11+
actions: 'test-handle',
1212
};
1313
const testStyles = {
1414
prefix: { color: 'red' },
1515
input: { color: 'blue' },
1616
suffix: { color: 'green' },
17-
handle: { color: 'yellow' },
17+
actions: { color: 'yellow' },
1818
};
1919
const { container } = render(
2020
<InputNumber
@@ -28,14 +28,14 @@ describe('InputNumber.Semantic', () => {
2828
const input = container.querySelector('.rc-input-number')!;
2929
const prefix = container.querySelector('.rc-input-number-prefix')!;
3030
const suffix = container.querySelector('.rc-input-number-suffix')!;
31-
const handle = container.querySelector('.rc-input-number-input-wrap')!;
31+
const actions = container.querySelector('.rc-input-number-input-wrap')!;
3232
expect(input.className).toContain(testClassNames.input);
3333
expect(prefix.className).toContain(testClassNames.prefix);
3434
expect(suffix.className).toContain(testClassNames.suffix);
35-
expect(handle.className).toContain(testClassNames.handle);
35+
expect(actions.className).toContain(testClassNames.actions);
3636
expect(prefix.style.color).toBe(testStyles.prefix.color);
3737
expect(input.style.color).toBe(testStyles.input.color);
3838
expect(suffix.style.color).toBe(testStyles.suffix.color);
39-
expect(handle.style.color).toBe(testStyles.handle.color);
39+
expect(actions.style.color).toBe(testStyles.actions.color);
4040
});
4141
});

0 commit comments

Comments
 (0)