menu
menu copied to clipboard
fix: wrong focus behavior when configuring menu selectability
This PR fixes issue https://github.com/ant-design/ant-design/issues/53495
Determine the focus key based on the selectable configuration:
If the item is not selectable, focus the default item.
If the item is selectable, decide whether to focus based on whether there is already a selected item.
Summary by CodeRabbit
-
Bug Fixes
- 优化菜单组件焦点选择与聚焦行为:当支持可选项时优先聚焦已选项(若存在且有效),否则回退到活跃项或计算的默认焦点;当不支持可选项时始终使用计算的默认焦点,简化并统一聚焦优先级与回退逻辑。
-
Tests
- 新增针对可选/不可选场景的焦点交互测试,覆盖键盘导航与点击、聚焦顺序与 focus 调用验证。