Skip to content
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: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

- Replace `"unset"` styles with safer override values
- Use capture phase for `"pointerdown"` and `"pointerup"` events; this is necessary for compatibility with certain UI libraries like Blueprint JS
- Read `Panel` pixel size using `offsetWidth`/`offsetHeight` rather than `inlineSize` to avoid an edgecase bug with `ResizeObserver`

## 4.3.0

- [583](https://github.com/bvaughn/react-resizable-panels/pull/583): `Group` component now sets default `width`, `height`, and `overflow` styles; (both can be overridden using the `style` property)
Expand Down
24 changes: 12 additions & 12 deletions lib/components/panel/Panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ describe("Panel", () => {

const panel = container.querySelector("[data-panel]") as HTMLElement;

expect(panel.style.minHeight).toBe("unset");
expect(panel.style.maxHeight).toBe("unset");
expect(panel.style.height).toBe("unset");

expect(panel.style.minWidth).toBe("unset");
expect(panel.style.maxWidth).toBe("unset");
expect(panel.style.width).toBe("unset");

expect(panel.style.border).toBe("unset");
expect(panel.style.borderWidth).toBe("unset");
expect(panel.style.padding).toBe("unset");
expect(panel.style.margin).toBe("unset");
expect(panel.style.minHeight).toBe("0");
expect(panel.style.maxHeight).toBe("100%");
expect(panel.style.height).toBe("auto");

expect(panel.style.minWidth).toBe("0");
expect(panel.style.maxWidth).toBe("100%");
expect(panel.style.width).toBe("auto");

expect(panel.style.border).toBe("0px");
expect(panel.style.borderWidth).toBe("0px");
expect(panel.style.padding).toBe("0px");
expect(panel.style.margin).toBe("0px");
});

describe("ARIA attributes", () => {
Expand Down
29 changes: 12 additions & 17 deletions lib/components/panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,16 @@ export function Panel({
Panel.displayName = "Panel";

const PROHIBITED_CSS_PROPERTIES: CSSProperties = {
minHeight: "unset",
maxHeight: "unset",
height: "unset",

minWidth: "unset",
maxWidth: "unset",
width: "unset",

flex: "unset",
flexBasis: "unset",
flexShrink: "unset",
flexGrow: "unset",

border: "unset",
borderWidth: "unset",
padding: "unset",
margin: "unset"
minHeight: 0,
maxHeight: "100%",
height: "auto",

minWidth: 0,
maxWidth: "100%",
width: "auto",

border: "none",
borderWidth: 0,
padding: 0,
margin: 0
};
12 changes: 8 additions & 4 deletions lib/global/mountGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ export function mountGroup(group: RegisteredGroup) {

// If this is the first group to be mounted, initialize event handlers
if (ownerDocumentReferenceCounts.get(ownerDocument) === 1) {
ownerDocument.addEventListener("pointerdown", onDocumentPointerDown);
ownerDocument.addEventListener("pointerdown", onDocumentPointerDown, true);
ownerDocument.addEventListener("pointerleave", onDocumentPointerLeave);
ownerDocument.addEventListener("pointermove", onDocumentPointerMove);
ownerDocument.addEventListener("pointerup", onDocumentPointerUp);
ownerDocument.addEventListener("pointerup", onDocumentPointerUp, true);
}

return function unmountGroup() {
Expand All @@ -197,10 +197,14 @@ export function mountGroup(group: RegisteredGroup) {

// If this was the last group to be mounted, tear down event handlers
if (!ownerDocumentReferenceCounts.get(ownerDocument)) {
ownerDocument.removeEventListener("pointerdown", onDocumentPointerDown);
ownerDocument.removeEventListener(
"pointerdown",
onDocumentPointerDown,
true
);
ownerDocument.removeEventListener("pointerleave", onDocumentPointerLeave);
ownerDocument.removeEventListener("pointermove", onDocumentPointerMove);
ownerDocument.removeEventListener("pointerup", onDocumentPointerUp);
ownerDocument.removeEventListener("pointerup", onDocumentPointerUp, true);
}

resizeObserver.disconnect();
Expand Down
11 changes: 7 additions & 4 deletions lib/global/utils/notifyPanelOnResize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ export function notifyPanelOnResize(

const groupSize = calculateAvailableGroupSize({ group });

const panelSize =
group.orientation === "horizontal"
? panel.element.offsetWidth
: panel.element.offsetHeight;

const prevSize = panel.mutableValues.prevSize;
const nextSize = {
asPercentage: formatLayoutNumber(
(resizeObserverSize.inlineSize / groupSize) * 100
),
inPixels: resizeObserverSize.inlineSize
asPercentage: formatLayoutNumber((panelSize / groupSize) * 100),
inPixels: panelSize
};
panel.mutableValues.prevSize = nextSize;

Expand Down
Loading