@@ -53,6 +53,9 @@ const Menu = {
53
53
created ( ) {
54
54
this . preProps = { ...this . $props }
55
55
} ,
56
+ updated ( ) {
57
+ this . propsUpdating = false
58
+ } ,
56
59
watch : {
57
60
mode ( val , oldVal ) {
58
61
if ( oldVal === 'inline' && val !== 'inline' ) {
@@ -63,59 +66,11 @@ const Menu = {
63
66
this . setState ( { sOpenKeys : val } )
64
67
} ,
65
68
inlineCollapsed ( val ) {
66
- if ( ! hasProp ( this , 'openKeys' ) ) {
67
- if ( val ) {
68
- this . switchingModeFromInline = true
69
- this . inlineOpenKeys = this . sOpenKeys
70
- this . setState ( { sOpenKeys : [ ] } )
71
- } else {
72
- this . setState ( { sOpenKeys : this . inlineOpenKeys } )
73
- this . inlineOpenKeys = [ ]
74
- }
75
- }
69
+ this . collapsedChange ( val )
76
70
} ,
77
- // '$props': {
78
- // handler: function (nextProps) {
79
- // const { preProps, sOpenKeys } = this
80
- // if (preProps.mode === 'inline' && nextProps.mode !== 'inline') {
81
- // this.switchingModeFromInline = true
82
- // }
83
- // if (hasProp(this, 'openKeys')) {
84
- // this.setState({ sOpenKeys: nextProps.openKeys })
85
- // this.preProps = { ...nextProps }
86
- // return
87
- // }
88
- // if (nextProps.inlineCollapsed && !preProps.inlineCollapsed) {
89
- // this.switchingModeFromInline = true
90
- // this.inlineOpenKeys = sOpenKeys
91
- // this.setState({ sOpenKeys: [] })
92
- // }
93
-
94
- // if (!nextProps.inlineCollapsed && preProps.inlineCollapsed) {
95
- // this.setState({ sOpenKeys: this.inlineOpenKeys })
96
- // this.inlineOpenKeys = []
97
- // }
98
- // this.preProps = { ...nextProps }
99
- // },
100
- // deep: true,
101
- // },
102
71
'layoutSiderContext.sCollapsed' : function ( val ) {
103
- const { openKeys, sOpenKeys = [ ] , prefixCls } = this
104
- if ( hasProp ( this , 'openKeys' ) ) {
105
- this . setState ( { sOpenKeys : openKeys } )
106
- return
107
- }
108
- if ( val ) {
109
- this . switchingModeFromInline =
110
- ! ! sOpenKeys . length && ! ! this . $el . querySelectorAll ( `.${ prefixCls } -submenu-open` ) . length
111
- this . inlineOpenKeys = sOpenKeys
112
- this . setState ( { sOpenKeys : [ ] } )
113
- } else {
114
- this . setState ( { sOpenKeys : this . inlineOpenKeys } )
115
- this . inlineOpenKeys = [ ]
116
- }
72
+ this . collapsedChange ( val )
117
73
} ,
118
-
119
74
} ,
120
75
data ( ) {
121
76
const props = this . $props
@@ -138,6 +93,20 @@ const Menu = {
138
93
}
139
94
} ,
140
95
methods : {
96
+ collapsedChange ( val ) {
97
+ if ( this . propsUpdating ) { return }
98
+ this . propsUpdating = true
99
+ if ( ! hasProp ( this , 'openKeys' ) ) {
100
+ if ( val ) {
101
+ this . switchingModeFromInline = true
102
+ this . inlineOpenKeys = this . sOpenKeys
103
+ this . setState ( { sOpenKeys : [ ] } )
104
+ } else {
105
+ this . setState ( { sOpenKeys : this . inlineOpenKeys } )
106
+ this . inlineOpenKeys = [ ]
107
+ }
108
+ }
109
+ } ,
141
110
restoreModeVerticalFromInline ( ) {
142
111
if ( this . switchingModeFromInline ) {
143
112
this . switchingModeFromInline = false
0 commit comments