Browse Source

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

wangweimin 2 năm trước cách đây
mục cha
commit
7c1c92f397
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  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);
         }