浏览代码

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

wangweimin 2 年之前
父节点
当前提交
7c1c92f397
共有 1 个文件被更改,包括 3 次插入2 次删除
  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);
         }