@@ -165,8 +165,8 @@ describe('PageLayout', async () => {
165165 )
166166
167167 const placeholder = await screen . findByText ( 'Pane' )
168- const pane = placeholder . parentNode
169- const initialWidth = ( pane as HTMLElement ) . style . getPropertyValue ( '--pane-width' )
168+ const pane = placeholder . parentNode as HTMLElement | null
169+ const initialWidth = pane ? .style . getPropertyValue ( '--pane-width' )
170170 const divider = await screen . findByRole ( 'slider' )
171171
172172 // Moving divider should resize pane.
@@ -176,11 +176,11 @@ describe('PageLayout', async () => {
176176 fireEvent . keyDown ( divider , { key : 'ArrowRight' } )
177177 fireEvent . keyDown ( divider , { key : 'ArrowRight' } )
178178
179- const finalWidth = ( pane as HTMLElement ) . style . getPropertyValue ( '--pane-width' )
179+ const finalWidth = pane ? .style . getPropertyValue ( '--pane-width' )
180180 expect ( finalWidth ) . not . toEqual ( initialWidth )
181181 } )
182182
183- it ( 'should set data-dragging attribute during pointer drag' , async ( ) => {
183+ it ( 'should set optimization styles during pointer drag' , async ( ) => {
184184 const { container} = render (
185185 < PageLayout >
186186 < PageLayout . Pane resizable >
@@ -192,22 +192,21 @@ describe('PageLayout', async () => {
192192 </ PageLayout > ,
193193 )
194194
195- const content = container . querySelector ( '[class*="PageLayoutContent "]' )
195+ const contentWrapper = container . querySelector < HTMLElement > ( '[class*="ContentWrapper "]' )
196196 const divider = await screen . findByRole ( 'slider' )
197197
198198 // Before drag - no data-dragging attribute
199- expect ( content ) . not . toHaveAttribute ( 'data-dragging' )
199+ expect ( contentWrapper ) . not . toHaveAttribute ( 'data-dragging' )
200200
201- // Start drag
201+ // Start drag - optimization attribute is set
202202 fireEvent . pointerDown ( divider , { clientX : 300 , clientY : 200 , pointerId : 1 } )
203- expect ( content ) . toHaveAttribute ( 'data-dragging' , 'true' )
204-
205- // End drag - pointer capture lost ends the drag and removes attribute
203+ expect ( contentWrapper ) . toHaveAttribute ( 'data-dragging' , 'true' )
204+ // End drag - pointer capture lost ends the drag and removes optimization attribute
206205 fireEvent . lostPointerCapture ( divider , { pointerId : 1 } )
207- expect ( content ) . not . toHaveAttribute ( 'data-dragging' )
206+ expect ( contentWrapper ) . not . toHaveAttribute ( 'data-dragging' )
208207 } )
209208
210- it ( 'should set data-dragging attribute during keyboard resize' , async ( ) => {
209+ it ( 'should set optimization styles during keyboard resize' , async ( ) => {
211210 const { container} = render (
212211 < PageLayout >
213212 < PageLayout . Pane resizable >
@@ -219,20 +218,46 @@ describe('PageLayout', async () => {
219218 </ PageLayout > ,
220219 )
221220
222- const content = container . querySelector ( '[class*="PageLayoutContent "]' )
221+ const contentWrapper = container . querySelector < HTMLElement > ( '[class*="ContentWrapper "]' )
223222 const divider = await screen . findByRole ( 'slider' )
224223
225224 // Before interaction - no data-dragging attribute
226- expect ( content ) . not . toHaveAttribute ( 'data-dragging' )
225+ expect ( contentWrapper ) . not . toHaveAttribute ( 'data-dragging' )
227226
228227 // Start keyboard resize (focus first)
229228 fireEvent . focus ( divider )
230229 fireEvent . keyDown ( divider , { key : 'ArrowRight' } )
231- expect ( content ) . toHaveAttribute ( 'data-dragging' , 'true' )
230+ expect ( contentWrapper ) . toHaveAttribute ( 'data-dragging' , 'true' )
232231
233- // End keyboard resize - removes attribute
232+ // End keyboard resize - removes optimization attribute
234233 fireEvent . keyUp ( divider , { key : 'ArrowRight' } )
235- expect ( content ) . not . toHaveAttribute ( 'data-dragging' )
234+ expect ( contentWrapper ) . not . toHaveAttribute ( 'data-dragging' )
235+ } )
236+
237+ it ( 'should not add will-change during drag' , async ( ) => {
238+ const { container} = render (
239+ < PageLayout >
240+ < PageLayout . Pane resizable >
241+ < Placeholder height = { 320 } label = "Pane" />
242+ </ PageLayout . Pane >
243+ < PageLayout . Content >
244+ < Placeholder height = { 640 } label = "Content" />
245+ </ PageLayout . Content >
246+ </ PageLayout > ,
247+ )
248+
249+ const pane = container . querySelector < HTMLElement > ( '[class*="Pane"][data-resizable]' )
250+ const divider = await screen . findByRole ( 'slider' )
251+
252+ // Before drag - no will-change
253+ expect ( pane ! . style . willChange ) . toBe ( '' )
254+
255+ // Start drag - will-change should still not be set (removed optimization)
256+ fireEvent . pointerDown ( divider , { clientX : 300 , clientY : 200 , pointerId : 1 } )
257+ expect ( pane ! . style . willChange ) . toBe ( '' )
258+ // End drag - will-change remains unset
259+ fireEvent . lostPointerCapture ( divider , { pointerId : 1 } )
260+ expect ( pane ! . style . willChange ) . toBe ( '' )
236261 } )
237262 } )
238263
0 commit comments