You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition, or possibly as a workaround can we get a prop that allows the visual mask to be optional?
This would also fix the issue of having the maskChar appear in the input field when typing, which can be annoying when you want to edit an incomplete entry and the cursor is placed at the end of the string, including the mask, and you have to move the cursor to before the mask characters before being able to type.
The way i'm currently working around this is by using onBlur to set the value to null when only the mask is showing.
constmaskChar='_';constdateFormat='dd-MM-yyyy';exportconstInlineDatePicker: React.FC<any>=props=>{const{
id,
value,
onChange,
label,
...restInput}=props;return(<KeyboardDatePickerid={id}variant="inline"margin="normal"label={label}value={value}{...restInput}format={dateFormat}maskChar={maskChar}onBlur={e=>handleBlur(e,props)}/>);};consthandleBlur=(e,props)=>{constdisplayValue: string=e.target.value;constmaskOnly=maskChar.repeat(dateFormat.length);// if the field is completely empty, only the mask is showingif(displayValue===maskOnly){if(props.onBlur){props.onBlur();}props.onChange(null);}};
Environment
Steps to reproduce
Expected behavior
When I don't have a value, the mask shouldn't stay. It should just go to initial state, which is no value.
Actual behavior
The mask stays and my input is marked as invalid. Even if I use Ctrl + A + Backspace I still get an Invalid field
Live example
You can see it in your docks
The text was updated successfully, but these errors were encountered: