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

Validation not working for MobileDatePicker& MobileTimePicker components #12497

Closed
mazenadel19 opened this issue Mar 19, 2024 · 3 comments
Closed
Labels
component: pickers This is the name of the generic UI component, not the React module!

Comments

@mazenadel19
Copy link

mazenadel19 commented Mar 19, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/sweet-moon-d4xl8x?file=%2Fsrc%2FDemo.js%3A45%2C10-45%2C26

Current behavior

form is submitting and ignoring MobileDatePicker& MobileTimePicker which are required and have no value, required seems to be set successfully on the html

image

Expected behavior

form shouldn't submit if there's no value for the MobileDatePicker or MobileTimePicker

Context

No response

Your environment

npx @mui/envinfo
System:
    OS: Windows 11 10.0.22621
  Binaries:
    Node: 16.20.2 - C:\Program Files\nodejs\node.EXE
    npm: 8.19.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
    Edge: Chromium (122.0.2365.52)
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4 
    @emotion/styled: ^11.11.0 => 11.11.0 
    @mui/base:  5.0.0-beta.39 
    @mui/core-downloads-tracker:  5.15.13 
    @mui/icons-material: ^5.15.12 => 5.15.12 
    @mui/lab: ^5.0.0-alpha.167 => 5.0.0-alpha.167 
    @mui/material: ^5.15.13 => 5.15.13 
    @mui/private-theming:  5.15.13 
    @mui/styled-engine:  5.15.11 
    @mui/styles: ^5.15.13 => 5.15.13 
    @mui/system:  5.15.12 
    @mui/types:  7.2.13 
    @mui/utils:  5.15.13 
    @mui/x-date-pickers: ^6.19.6 => 6.19.6 
    @types/react:  18.2.42 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    typescript:  3.9.10 

Search keywords: MobileDatePicker, Validation

@mazenadel19 mazenadel19 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 19, 2024
@zannager zannager added the component: pickers This is the name of the generic UI component, not the React module! label Mar 19, 2024
@mazenadel19 mazenadel19 changed the title Validation not working for MobileDatePicker component Validation not working for MobileDatePicker& MobileTimePicker components Mar 19, 2024
@LukasTy
Copy link
Member

LukasTy commented Mar 19, 2024

This is a side-effect of Mobile Pickers having the readonly prop.
We have a separate issue (#7869) for removing this prop.
@mui/explore WDYT, would it make sense to put the mentioned issue back to grooming and properly discuss, groom, and prioritize? Having it in "to explore" "Neverland" does not sound promising. 🙈

In the meantime, if you are fine with a not-ideal solution, consider overriding the readonly prop with:

<MobileDatePicker
  label="Mobile date"
  slotProps={{
    field: {
      readOnly: false,
    },
  }}
/>

@LukasTy LukasTy removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 19, 2024
@mazenadel19
Copy link
Author

I gave the solution a try, and it worked like a charm!
Thanks a bunch for your help, I'll go ahead and close this since I see you're already keeping an eye on the same issue elsewhere.

Copy link

⚠️ This issue has been closed.
If you have a similar problem, please open a new issue and provide details about your specific problem.
If you can provide additional information related to this topic that could help future readers, please feel free to leave a comment.

How did we do @mazenadel19?
Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants