feat: 调整 absolute 下拉控制组件定位逻辑,增加容器在有无 relative 下的处理#1987
Open
KMS-Bismarck wants to merge 7 commits intodevfrom
Open
feat: 调整 absolute 下拉控制组件定位逻辑,增加容器在有无 relative 下的处理#1987KMS-Bismarck wants to merge 7 commits intodevfrom
KMS-Bismarck wants to merge 7 commits intodevfrom
Conversation
leehaoChen
reviewed
Apr 17, 2023
src/AnimationList/AbsoluteList.tsx
Outdated
| const parent = target.parentElement | ||
|
|
||
| if (parent && parent.tagName === 'BODY') { | ||
| return document.body |
Contributor
There was a problem hiding this comment.
逻辑错误 当 target 为 body 下一层的时候 不是无条件返回 body ,应该判断target 得 position
src/AnimationList/AbsoluteList.tsx
Outdated
| const rootContainer = container === getRoot() || !container ? defaultContainer : container | ||
| const containerRect = rootContainer.getBoundingClientRect() | ||
| const nearestPositionDom = this.getNearestPositionDom(rootContainer) | ||
| const nearestPositionDomRect = nearestPositionDom.getBoundingClientRect() |
Contributor
There was a problem hiding this comment.
直接一开始就能判断出 实际的容器 只需要计算实际的容器即可, 简单清晰一些
src/AnimationList/AbsoluteList.tsx
Outdated
| overdoc = pos.left - containerRect.left + width + containerScroll.left > (containerRect.width || docSize.width) | ||
| overdoc = | ||
| pos.left + width + containerScroll.left - containerRect.left > | ||
| ((absolute ? docSize.width : containerRect.width) || docSize.width) |
added 3 commits
April 17, 2023 20:28
leehaoChen
reviewed
Apr 17, 2023
| const mergeStyle = Object.assign({}, style, this.state.overdoc ? getOverDocStyle(this.isRight()) : undefined) | ||
| const mergeStyle = Object.assign( | ||
| {}, | ||
| style, |
Contributor
There was a problem hiding this comment.
state 中存一个 offset , isRight 判断需要增加
added 2 commits
April 18, 2023 14:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
问题描述:
下拉控制组件在指定挂载容器的同时,开启 absolute 定位功能后,可能导致下拉菜单定位计算错误。
解决方案:
增加对挂载节点的容器或祖先容器是否存在 relative 的判断,根据最近的、非 static 定位的祖先元素,计算挂载位置。