Skip to content

Commit

Permalink
Specify elements to rerender in reparent & move strategies (#6448)
Browse files Browse the repository at this point in the history
## Description
Fill out `StrategyApplicationResult.elementsToRerender` with the element
path of the affected elements in some reparent, insert and drag
strategies
  • Loading branch information
bkrmendy authored Oct 2, 2024
1 parent 167ff05 commit 2706fcf
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ export function applyAbsoluteReparent(
},
)
} else {
const moveCommands =
return (
absoluteMoveStrategy(canvasState, interactionSession, {
...defaultCustomStrategyState(),
action: 'reparent',
})?.strategy.apply(strategyLifecycle).commands ?? []
return strategyApplicationResult(moveCommands, 'rerender-all-elements')
})?.strategy.apply(strategyLifecycle) ?? emptyStrategyApplicationResult
)
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,7 @@ function convertToAbsoluteAndMoveStrategyFactory(setHuggingParentToFixed: SetHug

return strategyApplicationResult(
[...absoluteMoveApplyResult.commands, strategyIndicatorCommand],
// 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',
absoluteMoveApplyResult.elementsToRerender,
)
}
// Fallback for when the checks above are not satisfied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,7 @@ function dragToInsertStrategyFactory(
reparentCommand,
...optionalWrappingCommand,
],
// 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.intendedParentPath],
{
strategyGeneratedUidsCache: {
[insertionSubjects[0].uid]: maybeWrapperWithUid?.uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,7 @@ export function drawToInsertStrategyFactory(
resizeCommand,
...optionalWrappingCommand,
],
// 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.intendedParentPath],
{
strategyGeneratedUidsCache: {
[insertionSubject.uid]: maybeWrapperWithUid?.uid,
Expand Down Expand Up @@ -352,10 +349,7 @@ export function drawToInsertStrategyFactory(

return strategyApplicationResult(
[insertionCommand.command, reparentCommand, ...optionalWrappingCommand],
// 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.intendedParentPath],
{
strategyGeneratedUidsCache: {
[insertionSubject.uid]: maybeWrapperWithUid?.uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ export const drawToInsertTextMetaStrategy: MetaCanvasStrategy = (
},
}),
],
// 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.intendedParentPath],
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,7 @@ export function ifAllowedToReparent(
if (allowed) {
return ifAllowed()
} else {
return strategyApplicationResult(
[setCursorCommand(CSSCursor.NotPermitted)],
'rerender-all-elements',
{},
'failure',
)
return strategyApplicationResult([setCursorCommand(CSSCursor.NotPermitted)], [], {}, 'failure')
}
}

Expand Down

0 comments on commit 2706fcf

Please sign in to comment.