Skip to content

Commit

Permalink
chore: set dropdown value if default/const is available
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj committed Jul 18, 2024
1 parent e1b9ae8 commit 0829688
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ export function JsonFormsDropdownControl({

// Use the default value if it exists
useEffect(() => {
handleChange(path, schema.default || schema.const)
}, [path, schema.default, schema.const, handleChange])
if (data !== undefined || data !== "") {
return
}
const value = schema.default || schema.const
setDropdownValue(value)
handleChange(path, value)
}, [path, schema.default, schema.const, handleChange, data])

if (!options || (options.length === 1 && !!schema.const)) {
return null
Expand Down

0 comments on commit 0829688

Please sign in to comment.