@@ -53,6 +53,9 @@ const Menu = {
5353 created ( ) {
5454 this . preProps = { ...this . $props }
5555 } ,
56+ updated ( ) {
57+ this . propsUpdating = false
58+ } ,
5659 watch : {
5760 mode ( val , oldVal ) {
5861 if ( oldVal === 'inline' && val !== 'inline' ) {
@@ -63,59 +66,11 @@ const Menu = {
6366 this . setState ( { sOpenKeys : val } )
6467 } ,
6568 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 )
7670 } ,
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- // },
10271 '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 )
11773 } ,
118-
11974 } ,
12075 data ( ) {
12176 const props = this . $props
@@ -138,6 +93,20 @@ const Menu = {
13893 }
13994 } ,
14095 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+ } ,
141110 restoreModeVerticalFromInline ( ) {
142111 if ( this . switchingModeFromInline ) {
143112 this . switchingModeFromInline = false
0 commit comments