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

[@mantine/dates] Fix: minimum-date is not in current month and value is not provided #5786

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,17 @@ export function Size() {
</div>
);
}

export function MinimumDateOnly() {
const [value, setValue] = useState<Date | null>(null);
return (
<div style={{ padding: 40, maxWidth: 400 }}>
<DateInput
placeholder="Enter date"
value={value}
onChange={setValue}
minDate={new Date('2024-05-01')}
/>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const DateInput = factory<DateInputFactory>((_props, ref) => {

useEffect(() => {
if (controlled) {
setDate(value!);
setDate(value ? value! : minDate!);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When clearable: true and you remove a selected value, visually it's removed from the UI however _date still gets set to the minDate instead of null.

}
}, [controlled, value]);

Expand Down