Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/code-studio/src/styleguide/Inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function Inputs(): React.ReactElement {
[]
);

const handleChange = (date: string) => {
Comment thread
mofojed marked this conversation as resolved.
Outdated
console.log('Date changed:', date);
};

return (
<div className="style-guide-inputs">
<h2 className="ui-title">Inputs</h2>
Expand Down Expand Up @@ -330,7 +334,7 @@ function Inputs(): React.ReactElement {
<TimeInput />
<br />
<h5>Date Input</h5>
<DateInput />
<DateInput onChange={handleChange} />
<br />
<h5>DateTime Input</h5>
<DateTimeInput />
Expand Down Expand Up @@ -363,5 +367,4 @@ function Inputs(): React.ReactElement {
</div>
);
}

export default Inputs;
14 changes: 2 additions & 12 deletions packages/components/src/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DATE_FORMAT = 'YYYY-MM-DD';

type DateInputProps = {
className?: string;
onChange?: (date?: string) => void;
onChange: (date: string) => void; // Remove the question mark to make date non-optional
Comment thread
sakibian marked this conversation as resolved.
Outdated
defaultValue?: string;
onFocus?: () => void;
onBlur?: () => void;
Expand All @@ -23,7 +23,7 @@ const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
(props: DateInputProps, ref) => {
const {
className = '',
onChange = () => undefined,
onChange = () => undefined, // Provide a default value for onChange
Comment thread
sakibian marked this conversation as resolved.
Outdated
defaultValue = '',
onFocus = () => undefined,
onBlur = () => undefined,
Expand Down Expand Up @@ -62,16 +62,6 @@ const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
);
}
);

DateInput.displayName = 'DateInput';

DateInput.defaultProps = {
Comment thread
sakibian marked this conversation as resolved.
className: '',
onChange: () => false,
defaultValue: '',
onFocus: () => false,
onBlur: () => false,
'data-testid': undefined,
};

export default DateInput;