Skip to content

fix: Use a select when parameter input has many options #3762

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

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions site/src/components/ParameterInput/ParameterInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FormControlLabel from "@material-ui/core/FormControlLabel"
import MenuItem from "@material-ui/core/MenuItem"
import Radio from "@material-ui/core/Radio"
import RadioGroup from "@material-ui/core/RadioGroup"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RadioGroup is not being used anymore. Suggested to remove import.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is for the boolean types

import { makeStyles } from "@material-ui/core/styles"
Expand Down Expand Up @@ -53,23 +54,23 @@ const ParameterField: React.FC<React.PropsWithChildren<ParameterInputProps>> = (
}) => {
if (schema.validation_contains && schema.validation_contains.length > 0) {
return (
<RadioGroup
<TextField
id={schema.name}
size="small"
defaultValue={schema.default_source_value}
disabled={disabled}
onChange={(event) => {
onChange(event.target.value)
}}
select
fullWidth
>
{schema.validation_contains.map((item) => (
<FormControlLabel
disabled={disabled}
key={item}
value={item}
control={<Radio color="primary" size="small" disableRipple />}
label={item}
/>
<MenuItem key={item} value={item}>
{item}
</MenuItem>
))}
</RadioGroup>
</TextField>
)
}

Expand Down