'React Autocomplete - Why is "required" not working?
Im following exactly what other examples have shown, but "required" is not working. Am I missing something?
<Autocomplete
id="exp-projects"
data-testid="select-projects"
options={projectOptions}
style={{ marginBottom: '1rem' }}
value={projects}
filterOptions={filterOptions}
getOptionLabel={({ name }) => name}
isOptionEqualToValue={(option, value) =>
value.id === option.id
}
onChange={(event, newValue) => setProjects(newValue)}
renderInput={(params) => (
<TextField
{...params}
inputProps={{
...params.inputProps,
required: projects.length === 0,
}}
data-testid="field-projects"
label="Projects"
required
/>
)}
multiple
/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
