Skip to content

Commit

Permalink
Add default value to select box.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Nov 25, 2024
1 parent cc05f56 commit 3de4d74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const FileWrapper = (props) => {
const ref = useRef();
const Widget = config.blocks.blocksConfig.schemaForm.innerWidgets.file;

console.log(value);

return (
<FormFieldWrapper {...props} className="text">
<Widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ const SelectWrapper = (props) => {
const options = choices || [];

return (
<FormFieldWrapper {...props} className="text">
<FormFieldWrapper {...props} className="select">
<Widget
id={`field-${id}`}
name={id}
value={value || undefined}
value={
(value && { value, label: value }) ||
(props.default && { value: props.default, label: props.default }) ||
undefined
}
label={title}
description={description}
disabled={isDisabled}
onChange={(value) => onChange(id, value === '' ? undefined : value)}
onChange={(value) => onChange(id, value.value)}
ref={ref}
onClick={() => onClick()}
options={options.map((option) => ({
Expand Down

0 comments on commit 3de4d74

Please sign in to comment.