From 47ea7cc21635b33ab43269879bf751d7979a07b9 Mon Sep 17 00:00:00 2001
From: zhigang.li <zhigang.li@tendcloud.com>
Date: Tue, 19 Dec 2017 20:42:15 +0800
Subject: [PATCH] fixed bug about sider

---
 src/components/layout/sider.vue | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/components/layout/sider.vue b/src/components/layout/sider.vue
index b3a782c..44657dc 100644
--- a/src/components/layout/sider.vue
+++ b/src/components/layout/sider.vue
@@ -56,7 +56,8 @@
         data () {
             return {
                 prefixCls: prefixCls,
-                mediaMatched: false
+                mediaMatched: false,
+                isCollapsed: false
             };
         },
         computed: {
@@ -64,13 +65,13 @@
                 return [
                     `${prefixCls}`,
                     this.siderWidth ? '' : `${prefixCls}-zero-width`,
-                    this.value ? `${prefixCls}-collapsed` : ''
+                    this.isCollapsed ? `${prefixCls}-collapsed` : ''
                 ];
             },
             triggerClasses () {
                 return [
                     `${prefixCls}-trigger`,
-                    this.value ? `${prefixCls}-trigger-collapsed` : '',
+                    this.isCollapsed ? `${prefixCls}-trigger-collapsed` : '',
                 ];
             },
             zeroWidthTriggerClasses () {
@@ -87,16 +88,17 @@
                 ];
             },
             siderWidth () {
-                return this.value ? (this.mediaMatched ? 0 : parseInt(this.collapsedWidth)) : parseInt(this.width);
+                return this.isCollapsed ? (this.mediaMatched ? 0 : parseInt(this.collapsedWidth)) : parseInt(this.width);
             },
             showZeroTrigger () {
-                return this.mediaMatched && !this.hideTrigger || (parseInt(this.collapsedWidth) === 0) && this.value && !this.hideTrigger;
+                return this.mediaMatched && !this.hideTrigger || (parseInt(this.collapsedWidth) === 0) && this.isCollapsed && !this.hideTrigger;
             }
         },
         methods: {
             toggleCollapse () {
-                this.$emit('input', !this.value);
-                this.$emit('on-collapse', !this.value);
+                this.isCollapsed = !this.isCollapsed;
+                this.$emit('input', !this.isCollapsed);
+                this.$emit('on-collapse', !this.isCollapsed);
             },
             matchMedia () {
                 let matchMedia;
@@ -105,7 +107,9 @@
                 }
                 let mediaMatched = this.mediaMatched;
                 this.mediaMatched = matchMedia(`(max-width: ${dimensionMap[this.breakpoint]})`).matches;
+                
                 if (this.mediaMatched !== mediaMatched) {
+                    this.isCollapsed = this.mediaMatched;
                     this.$emit('input', this.mediaMatched);
                     this.$emit('on-collapse', this.mediaMatched);
                 }
--
libgit2 0.21.4