Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dropdown-menu): 修复DropdownItem组件不受控 #1145

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

yiqia
Copy link
Contributor

@yiqia yiqia commented Oct 27, 2023

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

fix #1139

💡 需求背景和解决方案

dropdown-item不受控,排查发现问题出在dropdown-menu组件,没有及时更新,是因为在监听变化后返回了自身的label

label: label || menuTitles.value[index].label

不清楚为什么要使用自身的label,在上方已经有获取到的目标,就修改了取menuTitles改为了target,修复了动态修改没更新的问题。

const target = options?.find((item: any) => item[keys?.value ?? 'value'] === currentValue);

另外一个问题是展开和收缩之后,又自动修改回原来的label了,排查发现在展开时,没有重新赋值给state,于是添加了

state.itemsLabel[idx] = item.label;

📝 更新日志

  • fix(DropdownMenu): 解决 DropdownItem 组件的 label 属性不受控

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@github-actions
Copy link
Contributor

完成

@anlyyao anlyyao merged commit 3b7400c into Tencent:develop Oct 30, 2023
5 checks passed
@github-actions github-actions bot mentioned this pull request Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DropdownItem] 组件不受控
2 participants