Skip to content

[pickers] Report partially-filled date via onError #17499

Description

@ianparkinson

Summary

With MUI X v8, DatePicker now reports partially filled dates as null instead of as an invalid date object, as documented at https://mui.com/x/migration/migration-pickers-v7/#treat-partially-filled-date-as-null-in-onchange.

As far as I can tell, there's now no good way to distinguish between an empty DatePicker and a partially-filled one. If the date field is meant to be optional, then a UI cannot reject incomplete input while accepting an absent date.

Could partial input be reported via onError, either as invalidDate or some new error name?

Examples

Using the example at https://mui.com/x/react-date-pickers/validation/#show-the-error - deleting the year field causes the reported error to go away.

Motivation

Show a warning to a user who has tried to submit a form having only partially entered a date, in situations which otherwise allow the date to be omitted entirely.

Search keywords: partial date

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: pickersChanges related to the date/time pickers.type: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.type: new featureExpand the scope of the product to solve a new problem.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions