element-plus icon indicating copy to clipboard operation
element-plus copied to clipboard

fix(components): [cascader] update modelvalue problem

Open yuxuan-ctrl opened this issue 2 years ago • 8 comments

Please make sure these boxes are checked before submitting your PR, thank you!

  • [x] Make sure you follow contributing guide English | (中文 | Español | Français).
  • [x] Make sure you are merging your commits to dev branch.
  • [x] Add some descriptions and refer to relative issues for your PR.

Description

我发现我使用el-cascader的时候,在点击面板的选项后,更改v-model绑定的变量,cascader可以更新他值的变化,但是面板不会更新,同时输入框内展示的tags也不会更新

When I use el-cascader, After clicking on the options in the panel,I change the variable of the v-model(el-cascader) changes its content(checkValues), but not change the checkNodes. The cascade can update its value changes, but the panel will not be updated, and the tags displayed in the input box will not be updated either 现状(now):

🤖 Generated by Copilot at 6f61891

Fixed a cascader-panel bug that could overwrite user selection and added a feature to keep manual checked state. Modified index.vue to use a new variable and cloneDeep.

Related Issue

Fixes #14547 .

Explanation of Changes

经排查发现,在完成面板点击后,触发calculateCheckedValue方法,导致checkedValue更新。监听到props.modelValue会执行syncCheckedValue方法 。其中modelValue和 checkedValue.value会相同,会直接return掉,没有继续执行下面的syncMenuState方法,checkedNodes.value没有赋值为newNodes,导致tags和面板没有更新

🤖 Generated by Copilot at 6f61891

  • Add a variable hasManualChecked to track manual node selection in cascader panel ([link](https://github.com/element-plus/element-plus/pull/14806/files?diff=unified&w=0#diff-bc11d0a0926f24e07f0460209f0fc4632de9e2a8e47d0705fa07ff8678b71989R86), [link](https://github.com/element-plus/element-plus/pull/14806/files?diff=unified&w=0#diff-bc11d0a0926f24e07f0460209f0fc4632de9e2a8e47d0705fa07ff8678b71989L169-R170), [link](https://github.com/element-plus/element-plus/pull/14806/files?diff=unified&w=0#diff-bc11d0a0926f24e07f0460209f0fc4632de9e2a8e47d0705fa07ff8678b71989L217-R223))

yuxuan-ctrl avatar Nov 11 '23 10:11 yuxuan-ctrl

👋 @yuxuan-ctrl, seems like this is your first time contribution to element-plus.

  • Please make sure that you have read our guidelines and code of conduct before making a contribution.
  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

Hello @yuxuan-ctrl, thank you for contributing to element-plus, please see our guideline to see how to make contribution

github-actions[bot] avatar Nov 11 '23 10:11 github-actions[bot]

github-actions[bot] avatar Nov 11 '23 10:11 github-actions[bot]

/label Components:[cascader-panel]

yuxuan-ctrl avatar Nov 11 '23 17:11 yuxuan-ctrl

@btea 之前的逻辑有点错误,现在本地通过Unit test了,辛苦审核一下

yuxuan-ctrl avatar Nov 13 '23 03:11 yuxuan-ctrl

🧪 Playground Preview: https://element-plus.run/?pr=14806 Please comment the example via this playground if needed.

github-actions[bot] avatar Nov 14 '23 11:11 github-actions[bot]

🧪 Playground Preview: https://element-plus.run/?pr=14806 Please comment the example via this playground if needed. 这里是成功的例子 successExample这是失败的例子failExample Please approve it

yuxuan-ctrl avatar Nov 14 '23 12:11 yuxuan-ctrl

@btea @iamkun can anybody review this pull request? If it has any problem,please comment and I will work for it to fix.

yuxuan-ctrl avatar Dec 06 '23 02:12 yuxuan-ctrl