Skip to content

Commit a3d4b3c

Browse files
committed
refactor: rename onSingleChange to handleSingleChange for clarity
- Renamed function to follow event handler naming convention - Added explanatory comment for null date handling - Clarifies that null dates are delegated to onClear handler
1 parent fa46b0c commit a3d4b3c

File tree

1 file changed

+4
-2
lines changed
  • src/PickerInput/Selector/SingleSelector

1 file changed

+4
-2
lines changed

src/PickerInput/Selector/SingleSelector/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ function SingleSelector<DateType extends object = any>(
130130
const rootProps = useRootProps(restProps);
131131

132132
// ======================== Change ========================
133-
const onSingleChange = (date: DateType) => {
133+
const handleSingleChange = (date: DateType) => {
134134
if (date === null) {
135+
// When date is null (from manual clear), delegate to onClear handler
136+
// to properly trigger onChange and close the picker
135137
onClear?.();
136138
} else {
137139
onChange([date]);
@@ -154,7 +156,7 @@ function SingleSelector<DateType extends object = any>(
154156
const [getInputProps, getText] = useInputProps<DateType>(
155157
{
156158
...props,
157-
onChange: onSingleChange,
159+
onChange: handleSingleChange,
158160
},
159161
({ valueTexts }) => ({
160162
value: valueTexts[0] || '',

0 commit comments

Comments
 (0)