Skip to content

Commit

Permalink
[MISC][RL] Restore onSelectionCancel for range input
Browse files Browse the repository at this point in the history
  • Loading branch information
Quek Ruo Ling committed May 18, 2023
1 parent 1753392 commit dc1db1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/time-range-picker/time-range-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const TimeRangePicker = ({
readOnly,
onChange,
onBlur,
onSelectionCancel,
...otherProps
}: TimeRangePickerProps) => {
// =============================================================================
Expand Down Expand Up @@ -89,6 +90,7 @@ export const TimeRangePicker = ({
const handleSelectionDropdownCancel = () => {
setShowEndTimeSelector(false);
setShowStartTimeSelector(false);
onSelectionCancel && onSelectionCancel();
};

const handleStartTime = (value: string) => {
Expand Down
4 changes: 4 additions & 0 deletions src/time-range-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ export interface TimeRangePickerProps {
* Called when a defocus is made on the field
*/
onBlur?: (() => void) | undefined;
/**
* Called when the "Cancel" button is clicked
*/
onSelectionCancel?: (() => void) | undefined;
}
6 changes: 6 additions & 0 deletions stories/form/form-time-range-picker/props-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ const DATA: ApiTableSectionProps[] = [
description: "Called when a defocus happens",
propTypes: ["() => void"],
},
{
name: "onSelectionCancel",
description:
"Called when the user clicks on the 'Cancel' button in the time selection box. Any changes will not be applied",
propTypes: ["() => void"],
},
],
},
{
Expand Down

0 comments on commit dc1db1c

Please sign in to comment.