Skip to content

Commit

Permalink
Merge pull request #58 from mura-/fix/no-fields-bug
Browse files Browse the repository at this point in the history
fixed no fields bug
  • Loading branch information
mura- authored Oct 15, 2020
2 parents f46b305 + c4e5e09 commit 4002661
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/js/config/FormFieldSelectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ const useFormFieldSelectTable = (
) => {
const [appFields, setAppfields] = useState<FormField[]>([]);
const [selectedFields, setSelectedFields] = useState<FormField[]>(defaultSelectedFields);
useEffect(() => {
// reset initial value when no default selected fields
if (defaultSelectedFields.length === 0 && appFields.length > 0) {
setSelectedFields([{ code: appFields[0].code }]);
}
}, [appFields, defaultSelectedFields.length]);
const onChangeSelect = useCallback(
(event: SyntheticEvent<HTMLSelectElement>, index: number) => {
const value = event.currentTarget.value;
Expand Down

0 comments on commit 4002661

Please sign in to comment.