Browse Source

fix code textarea onchange fired when set value (#459)

wangweimin 2 years ago
parent
commit
7c1c92f397
1 changed files with 3 additions and 2 deletions
  1. 3 2
      webiojs/src/models/input/textarea.ts

+ 3 - 2
webiojs/src/models/input/textarea.ts

@@ -128,8 +128,9 @@ export class Textarea extends InputItem {
                 }
             }
             if (this.spec.onchange)
-                this.code_mirror.on('change', (instance: object, changeObj: object) => {
-                    this.on_input_event("change", this);
+                this.code_mirror.on('change', (instance: object, changeObj: any) => {
+                    if (changeObj.origin !== 'setValue')  // https://github.com/pywebio/PyWebIO/issues/459
+                        this.on_input_event("change", this);
                 })
             this.code_mirror.setSize(null, 20 * this.spec.rows);
         }