ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.1k stars 14.64k forks source link

[Bug Report] When dynamically set the disabled attribute of cascader's options, the children items of options will be disabled as expected, while the first-floor items are still abled. #19283

Open hayahayao opened 4 years ago

hayahayao commented 4 years ago

Element UI version

2.13.1

OS/Browsers version

chrome 81.0.4044.129

Vue version

2.6.11

Reproduction Link

https://codepen.io/azurecho/pen/VwvWbaG

Steps to reproduce

  1. selected one item of cascader (and the handleChange() method will set other first-floor item to be disabled)
  2. then re-check the cascader, you'll find other first-floor items are still abled, while their children are correctly disabled

What is Expected?

the first-floor items should also be set disabled

What is actually happening?

the first-floor items are still abled

hayahayao commented 4 years ago

And I think the problem maybe in Line 46 of cascader-panel/src/node.js

get isDisabled() {
    const { data, parent, config } = this;
    const disabledKey = config.disabled;
    const { checkStrictly } = config;
    return data[disabledKey] ||
      !checkStrictly && parent && parent.isDisabled; // here
}

because the first-floor nodes don't have parent, instead they have this.isDisabled.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.