mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix: 修复 table 获取滚动的父元素不准确的问题 (#5329)
This commit is contained in:
parent
a02f2a3d81
commit
227e77fab3
@ -630,25 +630,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
|
||||
componentDidMount() {
|
||||
const currentNode = findDOMNode(this) as HTMLElement;
|
||||
// 获取小于所有子元素高度之和的父元素
|
||||
let parent: HTMLElement | Window | null = getScrollParent(
|
||||
currentNode,
|
||||
parent => {
|
||||
if (parent.getAttribute('role') === 'dialog') {
|
||||
/**
|
||||
*
|
||||
* * 兼容在 Dialog 中的场景,
|
||||
* ! 有时 dialog 内容并没有撑出滚动条,这里需要做一下特殊处理
|
||||
* TODO 有没有一种更好的方式来判断
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
// * 具备 overflow-*:auto 的父元素的高度小于当前元素
|
||||
return (
|
||||
parent.offsetHeight > 0 && parent.offsetHeight < parent.scrollHeight
|
||||
);
|
||||
}
|
||||
);
|
||||
let parent: HTMLElement | Window | null = getScrollParent(currentNode);
|
||||
|
||||
if (!parent || parent === document.body) {
|
||||
parent = window;
|
||||
|
Loading…
Reference in New Issue
Block a user