Element: [Bug Report] Deselect sub-item (make it inactive) from menu

Created on 28 Sep 2018  ·  3Comments  ·  Source: ElemeFE/element

Element UI version

2.4.7

OS/Browsers version

any

Vue version

2.5.17

Reproduction Link

https://jsfiddle.net/mmx38qxw/6399/

Steps to reproduce

by default selected one sub-menu. When click on any sub-menu - they become active as well. But now, there's no way to deactivate that sub-menu.

Regression issue here: https://github.com/ElemeFE/element/commit/6bb49b959013f3351bee9308b2e627d80d857cfd

What is Expected?

Code should be fixed (removed this.items[this.activeIndex]) in order to be able to control active sub-menu.

What is actually happening?

Due to regression in https://github.com/ElemeFE/element/commit/6bb49b959013f3351bee9308b2e627d80d857cfd it's impossible to control active sub-menu now

Most helpful comment

Another way to solve it, you can just set activeIndex to a value that doesn't match any of your menu-items' index through this.refs['yourMenuRef'].activeIndex = 'xxx'
@industral

All 3 comments

May be you can have a try like this:
Set attribute default-active to 'placeholder' that produced by an invisible element <el-menu-item index="placeholder" v-show="false" />. It's not a final solution but seems to be 'unselected'.
It works to me. @industral

Thanks! Works for me as well. Had to change a lot of code though.

Another way to solve it, you can just set activeIndex to a value that doesn't match any of your menu-items' index through this.refs['yourMenuRef'].activeIndex = 'xxx'
@industral

Was this page helpful?
0 / 5 - 0 ratings