Skip to content

Commit

Permalink
Fix bad dev-conditionally around data attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Nov 13, 2023
1 parent 715ab01 commit 65a8e7a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/react-resizable-panels/src/Panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ export function PanelWithForwardedRef({

// CSS selectors
"data-panel": "",
"data-panel-id": panelId,

// e2e test attributes
"data-panel-collapsible": isDevelopment
? collapsible || undefined
: undefined,
"data-panel-id": isDevelopment ? panelId : undefined,
"data-panel-size": isDevelopment
? parseFloat("" + style.flexGrow).toFixed(1)
: undefined,
Expand Down
10 changes: 6 additions & 4 deletions packages/react-resizable-panels/src/PanelGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ function PanelGroupWithForwardedRef({
}

const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
if (groupSizePixels <= 0) {
// Wait until the group has rendered a non-zero size before computing layout.
return;
}

if (unsafeLayout == null) {
unsafeLayout = calculateUnsafeDefaultLayout({
Expand Down Expand Up @@ -925,10 +929,8 @@ function PanelGroupWithForwardedRef({

// CSS selectors
"data-panel-group": "",

// e2e test attributes
"data-panel-group-direction": isDevelopment ? direction : undefined,
"data-panel-group-id": isDevelopment ? groupId : undefined,
"data-panel-group-direction": direction,
"data-panel-group-id": groupId,
})
);
}
Expand Down
25 changes: 12 additions & 13 deletions packages/react-resizable-panels/src/PanelResizeHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,6 @@ export function PanelResizeHandle({
return createElement(Type, {
children,
className: classNameFromProps,

// CSS selectors
"data-resize-handle": "",

"data-resize-handle-active": isDragging
? "pointer"
: isFocused
? "keyboard"
: undefined,
"data-panel-group-direction": direction,
"data-panel-group-id": groupId,
"data-panel-resize-handle-enabled": !disabled,
"data-panel-resize-handle-id": resizeHandleId,
onBlur: () => setIsFocused(false),
onFocus: () => setIsFocused(true),
onMouseDown: (event: ReactMouseEvent) => {
Expand Down Expand Up @@ -192,6 +179,18 @@ export function PanelResizeHandle({
...styleFromProps,
},
tabIndex: 0,

// CSS selectors
"data-panel-group-direction": direction,
"data-panel-group-id": groupId,
"data-resize-handle": "",
"data-resize-handle-active": isDragging
? "pointer"
: isFocused
? "keyboard"
: undefined,
"data-panel-resize-handle-enabled": !disabled,
"data-panel-resize-handle-id": resizeHandleId,
});
}

Expand Down

0 comments on commit 65a8e7a

Please sign in to comment.