fix: `Menu` flashing problem when scaling under `Layout`
parent
b905d4f588
commit
9d35d80ca0
|
@ -53,6 +53,9 @@ const Menu = {
|
||||||
created () {
|
created () {
|
||||||
this.preProps = { ...this.$props }
|
this.preProps = { ...this.$props }
|
||||||
},
|
},
|
||||||
|
updated () {
|
||||||
|
this.propsUpdating = false
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
mode (val, oldVal) {
|
mode (val, oldVal) {
|
||||||
if (oldVal === 'inline' && val !== 'inline') {
|
if (oldVal === 'inline' && val !== 'inline') {
|
||||||
|
@ -63,59 +66,11 @@ const Menu = {
|
||||||
this.setState({ sOpenKeys: val })
|
this.setState({ sOpenKeys: val })
|
||||||
},
|
},
|
||||||
inlineCollapsed (val) {
|
inlineCollapsed (val) {
|
||||||
if (!hasProp(this, 'openKeys')) {
|
this.collapsedChange(val)
|
||||||
if (val) {
|
|
||||||
this.switchingModeFromInline = true
|
|
||||||
this.inlineOpenKeys = this.sOpenKeys
|
|
||||||
this.setState({ sOpenKeys: [] })
|
|
||||||
} else {
|
|
||||||
this.setState({ sOpenKeys: this.inlineOpenKeys })
|
|
||||||
this.inlineOpenKeys = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// '$props': {
|
|
||||||
// handler: function (nextProps) {
|
|
||||||
// const { preProps, sOpenKeys } = this
|
|
||||||
// if (preProps.mode === 'inline' && nextProps.mode !== 'inline') {
|
|
||||||
// this.switchingModeFromInline = true
|
|
||||||
// }
|
|
||||||
// if (hasProp(this, 'openKeys')) {
|
|
||||||
// this.setState({ sOpenKeys: nextProps.openKeys })
|
|
||||||
// this.preProps = { ...nextProps }
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if (nextProps.inlineCollapsed && !preProps.inlineCollapsed) {
|
|
||||||
// this.switchingModeFromInline = true
|
|
||||||
// this.inlineOpenKeys = sOpenKeys
|
|
||||||
// this.setState({ sOpenKeys: [] })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!nextProps.inlineCollapsed && preProps.inlineCollapsed) {
|
|
||||||
// this.setState({ sOpenKeys: this.inlineOpenKeys })
|
|
||||||
// this.inlineOpenKeys = []
|
|
||||||
// }
|
|
||||||
// this.preProps = { ...nextProps }
|
|
||||||
// },
|
|
||||||
// deep: true,
|
|
||||||
// },
|
|
||||||
'layoutSiderContext.sCollapsed': function (val) {
|
'layoutSiderContext.sCollapsed': function (val) {
|
||||||
const { openKeys, sOpenKeys = [], prefixCls } = this
|
this.collapsedChange(val)
|
||||||
if (hasProp(this, 'openKeys')) {
|
|
||||||
this.setState({ sOpenKeys: openKeys })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (val) {
|
|
||||||
this.switchingModeFromInline =
|
|
||||||
!!sOpenKeys.length && !!this.$el.querySelectorAll(`.${prefixCls}-submenu-open`).length
|
|
||||||
this.inlineOpenKeys = sOpenKeys
|
|
||||||
this.setState({ sOpenKeys: [] })
|
|
||||||
} else {
|
|
||||||
this.setState({ sOpenKeys: this.inlineOpenKeys })
|
|
||||||
this.inlineOpenKeys = []
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
const props = this.$props
|
const props = this.$props
|
||||||
|
@ -138,6 +93,20 @@ const Menu = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
collapsedChange (val) {
|
||||||
|
if (this.propsUpdating) { return }
|
||||||
|
this.propsUpdating = true
|
||||||
|
if (!hasProp(this, 'openKeys')) {
|
||||||
|
if (val) {
|
||||||
|
this.switchingModeFromInline = true
|
||||||
|
this.inlineOpenKeys = this.sOpenKeys
|
||||||
|
this.setState({ sOpenKeys: [] })
|
||||||
|
} else {
|
||||||
|
this.setState({ sOpenKeys: this.inlineOpenKeys })
|
||||||
|
this.inlineOpenKeys = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
restoreModeVerticalFromInline () {
|
restoreModeVerticalFromInline () {
|
||||||
if (this.switchingModeFromInline) {
|
if (this.switchingModeFromInline) {
|
||||||
this.switchingModeFromInline = false
|
this.switchingModeFromInline = false
|
||||||
|
|
Loading…
Reference in New Issue