Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最新版本子应用中agGrid使用setPopupParent将ag弹窗的父元素设置为子应用的body后,弹窗位置出现偏移 #1517

Open
edward492626 opened this issue Feb 6, 2025 · 2 comments

Comments

@edward492626
Copy link

edward492626 commented Feb 6, 2025

问题描述

问题的具体描述
为了解决agGrid高度过低时,右键菜单出现滚动条,使用setPopupParent将popup的父元素设置为子应用的body,设置后所有弹窗位置都出现了偏移,比如右键菜单、列上的tooltip,跟踪了下发现是在popupService中,

    getParentRect() {
        // subtract the popup parent borders, because popupParent.getBoundingClientRect
        // returns the rect outside the borders, but the 0,0 coordinate for absolute
        // positioning is inside the border, leading the popup to be off by the width
        // of the border
        const eDocument = this.gridOptionsService.getDocument();
        let popupParent = this.getPopupParent();
        if (popupParent === eDocument.body) {
            popupParent = eDocument.documentElement;
        }
        else if (getComputedStyle(popupParent).position === 'static') {
            popupParent = popupParent.offsetParent;
        }
        return getElementRectWithOffset(popupParent);
    }

eDocument的documentElement指向了父应用的根元素

复现步骤

1.在子应用中home页面中onGridReady事件中将params.api.setPopupParent(body);
2.鼠标悬停在grid的第一列第一行等待tooltip出现

上传截图

请上传代码截图、控制台、终端等截图以帮助我们了解您的问题。

Image

复现仓库

请提供一个精简的代码仓库,然后上传到自己的 github,以帮助我们复现您的问题。
https://github.com/edward492626/fix-scoped-css-bug

环境信息

  • micro-app版本:1.0.0-rc.20
  • 主应用前端框架&版本:vue 3.5.x
  • 子应用前端框架&版本:vue 3.5.x
  • 构建工具&版本:vite 5.x
@Zero1306
Copy link

Zero1306 commented Feb 7, 2025

遇到相同类似的问题Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

@htfire
Copy link

htfire commented Feb 19, 2025

遇到相同类似的问题Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

我这边也报错,

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants