mirror of
https://github.com/strapi/strapi.git
synced 2025-08-11 10:18:28 +00:00
started typography integration + fixed combobox created value crashing the app
This commit is contained in:
parent
ec8b6062a0
commit
8cbb331fff
@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
|
|||||||
import { ComboboxOption, CreatableCombobox } from '@strapi/design-system/Combobox';
|
import { ComboboxOption, CreatableCombobox } from '@strapi/design-system/Combobox';
|
||||||
import keys from './keys';
|
import keys from './keys';
|
||||||
|
|
||||||
const Combobox = ({ name, onChange, ...props }) => {
|
const Combobox = ({ name, onChange, value, ...props }) => {
|
||||||
const [options, setOptions] = useState(keys);
|
const [options, setOptions] = useState(value ? [...keys, value] : keys);
|
||||||
|
|
||||||
const handleChange = value => {
|
const handleChange = value => {
|
||||||
onChange({ target: { name, value } });
|
onChange({ target: { name, value } });
|
||||||
@ -22,6 +22,7 @@ const Combobox = ({ name, onChange, ...props }) => {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onCreateOption={handleCreateOption}
|
onCreateOption={handleCreateOption}
|
||||||
placeholder=""
|
placeholder=""
|
||||||
|
value={value}
|
||||||
>
|
>
|
||||||
{options.map(key => (
|
{options.map(key => (
|
||||||
<ComboboxOption value={key} key={key}>
|
<ComboboxOption value={key} key={key}>
|
||||||
@ -32,9 +33,14 @@ const Combobox = ({ name, onChange, ...props }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Combobox.defaultProps = {
|
||||||
|
value: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
Combobox.propTypes = {
|
Combobox.propTypes = {
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
value: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Combobox;
|
export default Combobox;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user