Skip to content

Commit

Permalink
Specify elements to rerender in grid strategies (#6443)
Browse files Browse the repository at this point in the history
## Problem
The grid strategies opt to rerender all elements in their strategy
result, which is adds a performance penalty.

## Fix
Only re-render the elements affected by a given strategy
  • Loading branch information
bkrmendy authored Oct 2, 2024
1 parent 2d558b0 commit 9dc2fa3
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ const gridDrawToInsertStrategyInner =
: null,
]),
],
// FIXME: This was added as a default value in https://github.com/concrete-utopia/utopia/pull/6408
// This was to maintain the existing behaviour, but it should be replaced with a more specific value
// appropriate to this particular case.
'rerender-all-elements',
[targetParent],
{
strategyGeneratedUidsCache: {
[insertionSubject.uid]: maybeWrapperWithUid?.uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ export function gridRearrangeResizeKeyboardStrategy(
gridRowStart,
gridRowEnd,
}),
// FIXME: This was added as a default value in https://github.com/concrete-utopia/utopia/pull/6408
// This was to maintain the existing behaviour, but it should be replaced with a more specific value
// appropriate to this particular case.
'rerender-all-elements',
[parentGridPath],
)
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ export const gridRearrangeMoveStrategy: CanvasStrategyFactory = (

return strategyApplicationResult(
[...midInteractionCommands, ...onCompleteCommands, ...commands],
// FIXME: This was added as a default value in https://github.com/concrete-utopia/utopia/pull/6408
// This was to maintain the existing behaviour, but it should be replaced with a more specific value
// appropriate to this particular case.
'rerender-all-elements',
[parentGridPath],
patch,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ export const gridResizeElementStrategy: CanvasStrategyFactory = (

return strategyApplicationResult(
setGridPropsCommands(selectedElement, gridTemplate, gridPropsWithDragOver(gridProps)),
// FIXME: This was added as a default value in https://github.com/concrete-utopia/utopia/pull/6408
// This was to maintain the existing behaviour, but it should be replaced with a more specific value
// appropriate to this particular case.
'rerender-all-elements',
[parentGridPath],
{
grid: { ...customState.grid, targetCellData: targetCell },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,7 @@ export const rearrangeGridSwapStrategy: CanvasStrategyFactory = (
return emptyStrategyApplicationResult
}

return strategyApplicationResult(
commands,
// FIXME: This was added as a default value in https://github.com/concrete-utopia/utopia/pull/6408
// This was to maintain the existing behaviour, but it should be replaced with a more specific value
// appropriate to this particular case.
'rerender-all-elements',
)
return strategyApplicationResult(commands, [EP.parentPath(selectedElement)])
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ export const resizeGridStrategy: CanvasStrategyFactory = (
}

if (!canResizeGridTemplate(originalValues)) {
return strategyApplicationResult(
[setCursorCommand(CSSCursor.NotPermitted)],
'rerender-all-elements',
)
return strategyApplicationResult([setCursorCommand(CSSCursor.NotPermitted)], [])
}

const expandedOriginalValues = expandGridDimensions(originalValues.dimensions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ export const setGridGapStrategy: CanvasStrategyFactory = (
if (shouldTearOffGapByAxis) {
return strategyApplicationResult(
[deleteProperties('always', selectedElement, [axisStyleProp])],
// FIXME: This was added as a default value in https://github.com/concrete-utopia/utopia/pull/6408
// This was to maintain the existing behaviour, but it should be replaced with a more specific value
// appropriate to this particular case.
'rerender-all-elements',
selectedElements,
)
}

Expand Down

0 comments on commit 9dc2fa3

Please sign in to comment.