Skip to content

Commit 822c3e7

Browse files
authored
Revert "Revert "Improve PageLayout pane drag performance with pointer capture and GPU-accelerated transforms"" (#7275)
1 parent d1a8984 commit 822c3e7

File tree

6 files changed

+858
-160
lines changed

6 files changed

+858
-160
lines changed

.changeset/olive-heads-enter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Improve drag performance for PageLayout

e2e/components/Axe.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const SKIPPED_TESTS = [
1414
'components-flash-features--with-icon-action-dismiss', // TODO: Remove once color-contrast issues have been resolved
1515
'components-flash-features--with-icon-and-action', // TODO: Remove once color-contrast issues have been resolved
1616
'components-filteredactionlist--default',
17+
'components-pagelayout-performance-tests--medium-content',
18+
'components-pagelayout-performance-tests--heavy-content',
1719
]
1820

1921
type Component = {

packages/react/src/PageLayout/PageLayout.module.css

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
/* Maintain resize cursor while dragging */
2-
/* stylelint-disable-next-line selector-no-qualifying-type */
3-
body[data-page-layout-dragging='true'] {
4-
cursor: col-resize;
5-
}
6-
7-
/* Disable text selection while dragging */
8-
/* stylelint-disable-next-line selector-no-qualifying-type */
9-
body[data-page-layout-dragging='true'] * {
10-
user-select: none;
11-
}
12-
131
.PageLayoutRoot {
142
/* Region Order */
153
--region-order-header: 0;
@@ -383,6 +371,26 @@ body[data-page-layout-dragging='true'] * {
383371
}
384372
}
385373

374+
/**
375+
* OPTIMIZATION: Aggressive containment during drag for ContentWrapper
376+
* CSS handles most optimizations automatically via :has() selector
377+
* JavaScript only handles scroll locking (can't be done in CSS)
378+
*/
379+
.PageLayoutContent:has(.DraggableHandle[data-dragging='true']) .ContentWrapper {
380+
/* Add paint containment during drag - safe since user can't interact */
381+
contain: layout style paint;
382+
383+
/* Disable interactions */
384+
pointer-events: none;
385+
386+
/* Disable transitions to prevent expensive recalculations */
387+
transition: none;
388+
389+
/* Force compositor layer for hardware acceleration */
390+
will-change: width;
391+
transform: translateZ(0);
392+
}
393+
386394
.Content {
387395
width: 100%;
388396

@@ -409,6 +417,16 @@ body[data-page-layout-dragging='true'] * {
409417
}
410418
}
411419

420+
/**
421+
* OPTIMIZATION: Freeze content layout during resize drag
422+
* This prevents expensive recalculations of large content areas
423+
* while keeping content visible (just frozen in place)
424+
*/
425+
.PageLayoutContent:has(.DraggableHandle[data-dragging='true']) .Content {
426+
/* Full containment (without size) - isolate from layout recalculations */
427+
contain: layout style paint;
428+
}
429+
412430
.PaneWrapper {
413431
display: flex;
414432
width: 100%;
@@ -598,6 +616,26 @@ body[data-page-layout-dragging='true'] * {
598616
}
599617
}
600618

619+
/**
620+
* OPTIMIZATION: Performance enhancements for Pane during drag
621+
* CSS handles all optimizations automatically - JavaScript only locks scroll
622+
*/
623+
.PaneWrapper:has(.DraggableHandle[data-dragging='true']) .Pane {
624+
/* Full containment - isolate from layout recalculations */
625+
contain: layout style paint;
626+
627+
/* Disable interactions during drag */
628+
pointer-events: none;
629+
630+
/* Disable transitions during drag */
631+
transition: none;
632+
633+
/* Force hardware acceleration */
634+
will-change: width, transform;
635+
transform: translateZ(0);
636+
backface-visibility: hidden;
637+
}
638+
601639
.PaneHorizontalDivider {
602640
&:where([data-position='start']) {
603641
/* stylelint-disable-next-line primer/spacing */
@@ -696,12 +734,22 @@ body[data-page-layout-dragging='true'] * {
696734
padding: var(--spacing);
697735
}
698736

737+
/**
738+
* DraggableHandle - Interactive resize handle
739+
*/
699740
.DraggableHandle {
700741
position: absolute;
701742
inset: 0 -2px;
702743
cursor: col-resize;
703744
background-color: transparent;
704745
transition-delay: 0.1s;
746+
747+
/**
748+
* OPTIMIZATION: Prevent touch scrolling and text selection during drag
749+
* This is done in CSS because it needs to be set before any pointer events
750+
*/
751+
touch-action: none;
752+
user-select: none;
705753
}
706754

707755
.DraggableHandle:hover {
@@ -710,6 +758,7 @@ body[data-page-layout-dragging='true'] * {
710758

711759
.DraggableHandle[data-dragging='true'] {
712760
background-color: var(--bgColor-accent-emphasis);
761+
cursor: col-resize;
713762
}
714763

715764
.DraggableHandle[data-dragging='true']:hover {

0 commit comments

Comments
 (0)