Skip to content

fix(popper): [tooltip,popover] fix popper doms in custom element, cant get zindex #3125

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/renderless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/vue-renderless",
"version": "3.21.1",
"version": "3.21.2",
"private": true,
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
"author": "OpenTiny Team",
Expand Down Expand Up @@ -36,8 +36,8 @@
"release": "esno ./scripts/postbuild.ts && shx cp README.md dist"
},
"dependencies": {
"color": "4.2.3",
"@opentiny/utils": "workspace:~"
"@opentiny/utils": "workspace:~",
"color": "4.2.3"
},
"devDependencies": {
"esno": "^4.7.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/renderless/src/common/deps/popper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const isFixed = (el: HTMLElement) => {
return true
}

// 处理遇到 shadowRoot的情况
if (el.host) {
el = el.host
}
return el.parentNode ? isFixed(el.parentNode as HTMLElement) : false
}

Expand Down
5 changes: 5 additions & 0 deletions packages/renderless/src/common/deps/vue-popper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const getReferMaxZIndex = (reference) => {
do {
reference = reference.parentNode

// 处理遇到shadowRoot的情况
if (reference && reference instanceof ShadowRoot && reference.host) {
reference = reference.host
}

if (reference) {
z = getZIndex(reference)
} else {
Expand Down
8 changes: 6 additions & 2 deletions packages/renderless/src/grid/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ export const colToVisible = ($table, column, move) => {
}

export const hasDataTag = (el, value) => {
// el可能为shadow-root,shadow-root没有getAttribute方法
if (!el || !value || !el.getAttribute) {
if (!el || !value) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the check for el.getAttribute could lead to runtime errors if el is not a valid DOM element or does not have the getAttribute method. Consider adding a check to ensure el is a valid DOM element before calling getAttribute. This will prevent potential runtime errors.

return false
}

// 处理遇到 shadowRoot的情况
if (el.host) {
el = el.host
}

return (' ' + el.getAttribute('data-tag') + ' ').includes(' ' + value + ' ')
}

Expand Down
Loading