fix(Select): dropdown rendering blank #7539 #7674
Open
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.
背景:
使用
dropdownRender
对ASelect
进行自由扩展,在ASelect
有焦点的情况下且滚动条滚动超过一页时,点击下拉会出现选项空白,完整讨论见 Issue,官方文档可复现。对比流程:
ASelect
不聚焦时,点击下拉框,会触发onContainerFocus
等方法,在onContainerFocus
方法中用setTimeout
延迟修改mockFocused
,mockFocused
变化会引起List
的onUpdated
的执行,此时列表已渲染完成,offsetHeight
能被正确赋值,触发了watcher
,更新state.scrollTop
,进而更新到calRes.offset
中。而
ASelect
聚焦时,点击下拉框,不会触发onContainerFocus
方法,导致offsetHeight
未能正确赋值,进而calRes.offset
未能正确计算,导致List
未能正确滚动到历史停留位置,出现选项空白。