Skip to content

Commit

Permalink
fix(web): change detection logic of schema setting (#1334)
Browse files Browse the repository at this point in the history
* fix: array sort only supportedTypes

* fix: apply a suggestion
  • Loading branch information
caichi-t authored Dec 5, 2024
1 parent 4204334 commit 6d986a4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions web/src/components/molecules/Schema/FieldModal/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,11 @@ export default (
}, [form, values]);

const handleValuesChange = useCallback(async (changedValues: Record<string, unknown>) => {
const [key, value] = Object.entries(changedValues)[0];
const [key, value] = Object.entries(changedValues)[0] as [keyof FormTypes, unknown];
let changedValue = value;
let defaultValue = defaultValueRef.current?.[key as keyof FormTypes];
if (Array.isArray(value)) {
let defaultValue = defaultValueRef.current?.[key];
if (key === "supportedTypes" && Array.isArray(value) && Array.isArray(defaultValue)) {
changedValue = [...value].sort();
}
if (Array.isArray(defaultValue)) {
defaultValue = [...defaultValue].sort();
}
if (JSON.stringify(emptyConvert(changedValue)) === JSON.stringify(emptyConvert(defaultValue))) {
Expand Down

0 comments on commit 6d986a4

Please sign in to comment.