Browse Source

fix: Add change event to "All" Option for TagSelect

HarpSun 5 years ago
parent
commit
dba14e3abb
1 changed files with 10 additions and 1 deletions
  1. 10 1
      src/components/TagSelect/index.jsx

+ 10 - 1
src/components/TagSelect/index.jsx

@@ -65,7 +65,16 @@ export default {
     },
     // CheckAll Button
     renderCheckAll () {
-      return !this.hideCheckAll && (<Option key={'total'} checked={this.localCheckAll} onChange={this.onCheckAll}>All</Option>) || null
+      const listeners = {
+        change: (checked) => {
+          this.onCheckAll(checked)
+          checked.value = 'total'
+          this.$emit('change', checked)
+        }
+      }
+      const checkAllElement = <Option key={'total'} checked={this.localCheckAll}>All</Option>
+      checkAllElement.componentOptions.listeners = listeners
+      return !this.hideCheckAll && checkAllElement || null
     },
     // expandable
     renderExpandable () {