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 3b27cb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 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: 8 additions & 3 deletions packages/react-resizable-panels/src/vendor/stacking-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const props =

/** @param {HTMLElement} node */
function is_flex_item(node: HTMLElement) {
// @ts-ignore
const display = getComputedStyle(get_parent(node) ?? node).display;
return display === "flex" || display === "inline-flex";
}
Expand Down Expand Up @@ -116,11 +117,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 +131,9 @@ function get_ancestors(node: HTMLElement) {

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

0 comments on commit 3b27cb2

Please sign in to comment.