-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[pickers] Add a required
prop
#7633
Comments
Please provide a CodeSandbox so that we can see how you use it, thanks! |
Since the issue is missing key information, and has been inactive for 7 days, it has been automatically closed. |
That can be passed separately in InputProps and handled in your own renderInput like this: import { useCallback, useMemo } from 'react';
import { DatePicker } from '@mui/x-date-pickers';
import { TextField } from '@mui/material';
const renderInput = (params) => {
return <TextField {...params} required={params.InputProps.required} />;
};
const dayOfWeekFormatter = (day) => day.charAt(1);
const views = ['day', 'month', 'year'];
export default ({ value, key, setValue, name, required, label, ...props }) => {
const callback = useCallback(() => {
setValue((x) => ({ ...x, [key]: value }));
}, [setValue, key]);
const DialogProps = useMemo(() => ({ 'data-name': name }), [name]);
const InputProps = useMemo(() => ({ required }), [required]);
return (
<DatePicker
inputFormat="YYYY-MM-DD"
dayOfWeekFormatter={dayOfWeekFormatter}
value={value}
onChange={callback}
renderInput={renderInput}
DialogProps={DialogProps}
PopperProps={DialogProps}
InputProps={InputProps}
views={views}
label={label}
{...props}
/>
);
}; Injecting |
I'm reopening because I do agree we could have a better DX on that one. |
required
prop
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. |
Given that we support various validation options, I feel that we are sort of missing one of the most important validations— For this very reason, it does not reasonable to avoid adding such basic validation controls, because more often than not users might be controlling the error state to achieve their desired UX anyways. 🤔 What do you think @flaviendelangle? |
Could you elaborate here? I'm not following you. |
I meant that if we add a In essence, adding this prop does sound useful as there does not seem to be any clear drawbacks. 🤔 |
I'm not sure we can make the native |
Let's discuss it during grooming yes! |
Was there any decision on this during the grooming @flaviendelangle ? |
I believe that we decided to introduce the top-level prop and add this validation in a similar manner that we have the other validation props. |
And have it work with our multi-HTML-input structure of v7 😬 |
@LukasTy we would like to pick this up |
Thank you for expressing the interest. 🙏 |
Is there any progress on this issue? |
@gitstart Do you have any updates on the progress? |
Hi @LukasTy, thanks for checking in. |
Thank you for the update, no worries. 👌 |
Any updates on this? |
Looks like there is no update for now. Is it a blocker for your use case? |
Duplicates
Latest version
Current behavior 😯
Expected behavior 🤔
Steps to reproduce 🕹
Steps:
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: