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
If a Field with type {CheckboxWithLabel} is used, it kills Chrome's autofill functionality. Fields before the checkbox lose autofill.
Actually, I'm not sure if this is a MUI, a formik-mui or a Formik bug, but, as I tested it mostly with the Field component and with a formik-mui component type, I submit the bug report here.
Everything I use is the of latest version: formik-mui: 4.0.0-alpha.2, MUI 5.2.1, Formik 2.2.9.
Expected Behavior 🤔
Well, obviously, the expected behaviour is components not killing a must-have functionality of the most popular browser. :)
Steps to Reproduce 🕹
All I can add here is the code I actually have:
importlogofrom'./logo.svg';import'./App.css';importReact,{useState}from'react';import{Field,Form,Formik,FormikConfig,FormikValues,useFormik}from'formik';import{mixed,number,object}from'yup';import{Box,Button,Card,CardContent,CircularProgress,Grid,Step,StepLabel,Stepper,Typography,Slider}from'@mui/material';import{spacing}from'@mui/system';import{CheckboxWithLabel,TextField,Checkbox}from'formik-mui';import{experimentalStyledasstyled,createTheme,ThemeProvider}from"@mui/material/styles";import{blue,grey}from'@mui/material/colors';importCssBaselinefrom'@mui/material/CssBaseline';constsleep=(ms)=>newPromise((r)=>setTimeout(r,ms));constCustomizedSlider=styled(Slider)` color: #20b2aa; transition: all .2s ease-in-out; :hover { color: #2e8b57; }`;consttheme=createTheme({spacing: 8,palette: {primary: blue,background: {paper: '#f6f6f6',},},})constlightGrey=grey[100];exportdefaultfunctionApp(){constformik=useFormik({initialValues: {kmpFieldEmail: '[email protected]',kmpFieldName: '',kmpFieldNewsletter: true,},onSubmit: asyncvalues=>{awaitsleep(2000);alert(JSON.stringify(values,null,2));},});return(<ThemeProvidertheme={theme}><Cardsx={{bgcolor: 'background.paper'}}><CardContent><FormikStepperinitialValues={formik.values}onSubmit={formik.handleSubmit}><FormikSteplabel="Personal Details"><Boxsx={{pb:2}}><Fieldfullwidthtype="text"name="kmpFieldName"component={TextField}label="Name"inputProps={{onChange:formik.handleChange}}value={formik.values.kmpFieldName}placeholder=""/></Box><Boxsx={{pb:2}}><Fieldfullwidthtype="email"name="kmpFieldEmail"component={TextField}label="Email"inputProps={{onChange:formik.handleChange}}value={formik.values.kmpFieldEmail}placeholder=""/></Box><labelhtmlFor="email">Email Address</label><inputid="email"name="email"type="text"style={{display:'none'}}/><Boxsx={{pb:2}}><Fieldtype="checkbox"name="kmpFieldNewsletter"component={CheckboxWithLabel}Label={{label: 'Yes, I want to subscribe'}}inputProps={{onChange:formik.handleChange}}checked={formik.values.kmpFieldNewsletter==true ? true : false}/></Box></FormikStep><FormikSteplabel="Calorie Information"validationSchema={object({money: mixed().when('millionaire',{is: true,then: number().required().min(1_000_000,'Because you said you are a millionaire you need to have 1 million'),otherwise: number().required(),}),})}><Boxsx={{pb:2}}><Typographyid="kmp-label--calorie-slider"gutterBottom>
Select how many calories you’d like your interactive sliding meal plan to follow:
</Typography><CustomizedSlideraria-label="Calorie Target"defaultValue={1800}valueLabelDisplay="auto"step={100}marksmin={1200}max={2500}/><Typographyid="kmp-sublabel--calorie-slider"gutterBottom>
Need help? Visit our <ahref="/calculator/"target="_blank">Keto Calculator</a>.
</Typography></Box></FormikStep><FormikSteplabel="Personal Preferences"><Boxsx={{pb:2}}><Fieldfullwidthtype="email"name="kmpFieldEmail"component={TextField}label="Email"//inputProps={{ onChange:props.handleChange }}placeholder=""/></Box></FormikStep></FormikStepper></CardContent></Card></ThemeProvider>);}exportinterfaceFormikStepPropsextendsPick<FormikConfig<FormikValues>,'children'|'validationSchema'>{label: string;}exportfunctionFormikStep({ children }: FormikStepProps){return<>{children}</>;}exportfunctionFormikStepper({ children, ...props}: FormikConfig<FormikValues>) {constchildrenArray=React.Children.toArray(children)asReact.ReactElement<FormikStepProps>[];const[step,setStep]=useState(0);constcurrentChild=childrenArray[step];const[completed,setCompleted]=useState(false);constalertShit=function(){alert('Shit');}functionisLastStep(){returnstep===childrenArray.length-1;}return(<Formik{...props}validationSchema={currentChild.props.validationSchema}onSubmit={async(values,helpers)=>{if(isLastStep()){awaitprops.onSubmit(values,helpers);setCompleted(true);}else{setStep((s)=>s+1);// If you have multiple fields on the same step// we will see they show the validation error all at the same time after the first step!//// If you want to keep that behaviour, then, comment the next line :)// If you want the second/third/fourth/etc steps with the same behaviour// as the first step regarding validation errors, then the next line is for you! =)helpers.setTouched({});}}}>{({ isSubmitting })=>(<Form><StepperalternativeLabelactiveStep={step}sx={{mb: 4}}>{childrenArray.map((child,index)=>(<Stepkey={child.props.label}completed={step>index||completed}><StepLabel>{child.props.label}</StepLabel></Step>))}</Stepper>{currentChild}<Gridcontainersx={{mt:4}}justifyContent="space-between">{step>0 ? (<Griditem><Buttondisabled={isSubmitting}variant="contained"color="primary"onClick={()=>setStep((s)=>s-1)}>
Back
</Button></Grid>) : null}<Griditem><ButtonstartIcon={isSubmitting ? <CircularProgresssize="1rem"/> : null}disabled={isSubmitting}variant="contained"color="primary"type="submit">{isSubmitting ? 'Submitting' : isLastStep() ? 'Submit' : 'Next'}</Button></Grid></Grid></Form>)}</Formik>);}
This code works - but if you remove the fixing snippet:
FYKI: the file is typescript (with .tsx extension) - but it doesn't matter. I tested the issue without the stuff written in typescript and the file rebaptised to .js, and the result is the same.
Thanks for investigating this further.
The text was updated successfully, but these errors were encountered:
Current Behavior 😯
If a Field with type {CheckboxWithLabel} is used, it kills Chrome's autofill functionality. Fields before the checkbox lose autofill.
Actually, I'm not sure if this is a MUI, a formik-mui or a Formik bug, but, as I tested it mostly with the Field component and with a formik-mui component type, I submit the bug report here.
Everything I use is the of latest version: formik-mui: 4.0.0-alpha.2, MUI 5.2.1, Formik 2.2.9.
Expected Behavior 🤔
Well, obviously, the expected behaviour is components not killing a must-have functionality of the most popular browser. :)
Steps to Reproduce 🕹
All I can add here is the code I actually have:
This code works - but if you remove the fixing snippet:
... then Chrome's autofill doesn't work anymore.
FYKI: the file is typescript (with .tsx extension) - but it doesn't matter. I tested the issue without the stuff written in typescript and the file rebaptised to .js, and the result is the same.
Thanks for investigating this further.
The text was updated successfully, but these errors were encountered: