fix(explore): dispatch onChange immediately on NumberControl stepper arrow clicks (#39220)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Abdul Rehman
2026-04-15 22:15:37 +05:00
committed by GitHub
parent 18d6feb499
commit 44e77fdf2b
2 changed files with 21 additions and 0 deletions

View File

@@ -82,6 +82,21 @@ test('can clear field completely', async () => {
expect(props.onChange).toHaveBeenLastCalledWith(undefined);
});
test('stepper arrows trigger onChange immediately', async () => {
const props = {
...mockedProps,
value: 5,
onChange: jest.fn(),
};
render(<NumberControl {...props} />);
const upButton = document.querySelector(
'.ant-input-number-handler-up',
) as HTMLElement;
expect(upButton).toBeInTheDocument();
await userEvent.click(upButton);
expect(props.onChange).toHaveBeenCalledWith(6);
});
test('updates local value when prop changes', () => {
const props = {
...mockedProps,

View File

@@ -71,6 +71,11 @@ export default function NumberControl({
onChange?.(pendingValueRef.current);
};
const handleStep = (val: number) => {
pendingValueRef.current = val;
onChange?.(val);
};
return (
<FullWidthDiv>
<ControlHeader {...rest} />
@@ -82,6 +87,7 @@ export default function NumberControl({
value={value}
onChange={handleChange}
onBlur={handleBlur}
onStep={handleStep}
disabled={disabled}
aria-label={rest.label}
/>