Skip to content

Commit c684b6f

Browse files
authored
fix: RangePicker double click should only act on needConfirm case (#760)
* fix: double click should not effect on simply picker * test: add test case * chore: clean up
1 parent 1f725d0 commit c684b6f

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

src/PickerInput/Popup/PopupPanel.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ export type PopupPanelProps<DateType extends object = any> = MustProp<DateType>
2121
export default function PopupPanel<DateType extends object = any>(
2222
props: PopupPanelProps<DateType>,
2323
) {
24-
const { picker, multiplePanel, pickerValue, onPickerValueChange, onSubmit, range, hoverValue } =
25-
props;
24+
const {
25+
picker,
26+
multiplePanel,
27+
pickerValue,
28+
onPickerValueChange,
29+
needConfirm,
30+
onSubmit,
31+
range,
32+
hoverValue,
33+
} = props;
2634
const { prefixCls, generateConfig } = React.useContext(PickerContext);
2735

2836
// ======================== Offset ========================
@@ -46,7 +54,9 @@ export default function PopupPanel<DateType extends object = any>(
4654
// ======================= Context ========================
4755
const sharedContext: PickerHackContextProps = {
4856
onCellDblClick: () => {
49-
onSubmit();
57+
if (needConfirm) {
58+
onSubmit();
59+
}
5060
},
5161
};
5262

src/PickerInput/hooks/useFilledProps.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,12 @@ export default function useFilledProps<
211211
[filledProps, mergedNeedConfirm, mergedInputReadOnly, disabledBoundaryDate],
212212
);
213213

214-
return [mergedProps, internalPicker, complexPicker, formatList, maskFormat, isInvalidateDate];
214+
return [
215+
mergedProps,
216+
internalPicker,
217+
complexPicker,
218+
formatList,
219+
maskFormat,
220+
isInvalidateDate,
221+
];
215222
}

tests/new-range.spec.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,19 @@ describe('NewPicker.Range', () => {
732732
'1990-09-05 11:00:00',
733733
]);
734734
});
735+
736+
it('double click should not take action if !needConfirm', () => {
737+
const { container } = render(<DayRangePicker />);
738+
739+
openPicker(container);
740+
741+
fireEvent.click(findCell(5));
742+
fireEvent.click(findCell(5));
743+
fireEvent.doubleClick(findCell(5));
744+
745+
expect(container.querySelectorAll('input')[0]).toHaveValue('1990-09-05');
746+
expect(container.querySelectorAll('input')[1]).toHaveValue('1990-09-05');
747+
});
735748
});
736749

737750
describe('open', () => {

0 commit comments

Comments
 (0)