Skip to content

Commit

Permalink
fix: parent cycle problem
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Mar 14, 2024
1 parent 61ba611 commit 36a7f57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Root, createRoot } from "react-dom/client";
import { act } from "react-dom/test-utils";
import type { PanelResizeHandleProps } from "react-resizable-panels";
import type { PanelResizeHandleProps } from "./PanelResizeHandle";
import { Panel, PanelGroup, PanelResizeHandle } from ".";
import { assert } from "./utils/assert";
import { getResizeHandleElement } from "./utils/dom/getResizeHandleElement";
Expand Down
11 changes: 9 additions & 2 deletions packages/react-resizable-panels/src/vendor/stacking-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ function get_z_index(node: HTMLElement | null) {
}

/** @param {HTMLElement} node */
function get_ancestors(node: HTMLElement) {
function get_ancestors(node: HTMLElement | null) {
const ancestors = [];

while (node) {
ancestors.push(node);
// @ts-ignore
node = get_parent(node);
}

Expand All @@ -129,6 +130,12 @@ function get_ancestors(node: HTMLElement) {

/** @param {HTMLElement} node */
function get_parent(node: HTMLElement) {
const { parentNode } = node;
// @ts-ignore
return node.parentNode?.host;
if (parentNode && parentNode.host && parentNode.host instanceof ShadowRoot) {
// @ts-ignore
return parentNode.host.getRootNode()

}
return parentNode;
}

0 comments on commit 36a7f57

Please sign in to comment.