fix: nav hover will lost open state in collapse mode, close #2558 #2559
+33
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
中文模板 / Chinese Template
What kind of change does this PR introduce? (check at least one)
PR description
原有的 SubNav 中,将 openKeys的更新耦合在了两个操作中: updateOpen时,判断 dropdown的 visible决定是 addOpenKeys,还是 removeOpenKeys。
foundation 中 调用 updateOpen时,无法直接决定 newOpenKeys。但是实际上在两处仅有的 updateOpen调用中,它的前一步骤已经把最新的 newOpenKeys算出来了,没有必要再在 updateOpen adapter中重新计算。此处应该信赖直接更新即可
nax-context 补充类型声明,实际上在 nav /index.tsx中已经通过 context往下传了 updateOpenKeys、addOpenKeys、removeOpenKeys三个操作函数,但因为之前代码中是通过
this._invokeContextFunc(isOpen ? 'addOpenKeys' : 'removeOpenKeys', this.props.itemKey
这种方式调用的,绕过了类型检测,所以并没有检测出类型缺失。subNavFoundation中增加检测,如果hover时,这个 item已经是open状态,无论dropdown 由 show -> hide还是由 hide -> show,都不再修改 openKeys,解决 [Nav] in collapse mode hover item will lost open state which exist before collapse #2558 的问题
Changelog
🇨🇳 Chinese
🇺🇸 English
Checklist
Other
Additional information