mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user