Skip to content

Commit 309349f

Browse files
onChange should be fired only if the schema is in the current page (#965)
* onChange should be fired only if the schema is in the current page * Update packages/ui/src/components/Designer/Canvas/index.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * make the function inline to avoid type errors --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent 34e9f49 commit 309349f

File tree

1 file changed

+12
-6
lines changed
  • packages/ui/src/components/Designer/Canvas

1 file changed

+12
-6
lines changed

packages/ui/src/components/Designer/Canvas/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,18 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
514514
value={value}
515515
onChangeHoveringSchemaId={onChangeHoveringSchemaId}
516516
mode={mode}
517-
onChange={(arg) => {
518-
// Use type assertion to safely handle the argument
519-
type ChangeArg = { key: string; value: unknown };
520-
const args = Array.isArray(arg) ? (arg as ChangeArg[]) : [arg as ChangeArg];
521-
changeSchemas(args.map(({ key, value }) => ({ key, value, schemaId: schema.id })));
522-
}}
517+
onChange={
518+
schemasList[pageCursor].some((s) => s.id === schema.id)
519+
? (arg) => {
520+
// Use type assertion to safely handle the argument
521+
type ChangeArg = { key: string; value: unknown };
522+
const args = Array.isArray(arg) ? (arg as ChangeArg[]) : [arg as ChangeArg];
523+
changeSchemas(
524+
args.map(({ key, value }) => ({ key, value, schemaId: schema.id })),
525+
);
526+
}
527+
: undefined
528+
}
523529
stopEditing={() => setEditing(false)}
524530
outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
525531
schema.readOnly && hoveringSchemaId !== schema.id

0 commit comments

Comments
 (0)