Skip to content

Commit

Permalink
Add support for prop on Select (fixes #2347)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchamberlain authored and lucas-koehler committed Jul 24, 2024
1 parent d3ee13a commit ee3c12e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/material-renderers/src/mui-controls/MuiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import { EnumCellProps, WithClassname } from '@jsonforms/core';
import { MenuItem, Select } from '@mui/material';
import merge from 'lodash/merge';
import { TranslateProps } from '@jsonforms/react';
import { i18nDefaults, WithInputProps } from '../util';
import { i18nDefaults, WithInputProps, WithSelectProps } from '../util';

export const MuiSelect = React.memo(function MuiSelect(
props: EnumCellProps & WithClassname & TranslateProps & WithInputProps
props: EnumCellProps & WithClassname & TranslateProps & WithInputProps & WithSelectProps
) {
const {
data,
Expand All @@ -46,6 +46,7 @@ export const MuiSelect = React.memo(function MuiSelect(
config,
label,
t,
multiple
} = props;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
const noneOptionLabel = useMemo(
Expand All @@ -63,6 +64,7 @@ export const MuiSelect = React.memo(function MuiSelect(
value={data !== undefined ? data : ''}
onChange={(ev) => handleChange(path, ev.target.value || undefined)}
fullWidth={true}
multiple={multiple || false}
>
{[
<MenuItem value={''} key='jsonforms.enum.none'>
Expand Down
4 changes: 4 additions & 0 deletions packages/material-renderers/src/util/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export interface WithInputProps {
label?: string;
}

export interface WithSelectProps {
multiple?: boolean;
}

const variantToInput = {
standard: Input,
filled: FilledInput,
Expand Down

0 comments on commit ee3c12e

Please sign in to comment.