Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Date argument non-optional for the onChange prop #1622

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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) => {
mofojed marked this conversation as resolved.
Show resolved Hide resolved
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;
12 changes: 1 addition & 11 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;
defaultValue?: string;
onFocus?: () => void;
onBlur?: () => void;
Expand Down Expand Up @@ -62,16 +62,6 @@ const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
);
}
);

DateInput.displayName = 'DateInput';

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

export default DateInput;