-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified layout multi-select support. #4376
Conversation
- Moved `changeBounds` and `ChangeBoundsResult` to `shared-absolute-resize-strategy-helpers.ts`. - Added `resizeInspectorStrategy` and `directResizeInspectorStrategy`. - Extracted out `getAppropriateLocalFrame` as the logic was needed/used in more than one place. - Implemented `getDirectMoveCommandsForSelectedElement`. - Added `startingFeatureSwitches` parameter to `renderTestEditorWithCode`. - Changed `originalLocalFrame` to `originalLTWHValues` so that we can instead capture plurality of the positional/sizing properties. - Added a `FrameUpdate` type to the simplified layout section to capture delta changes versus direct (where the property is set to a specific value) changes. - `updateFrame` callback extended to support the differing types of updates by executing differing inspector strategies.
Job #8693: Bundle Size — 63.29MiB (+0.02%).
Warning Bundle contains 64 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
View job #8693 report View feature/multiselect-layout-pins-... branch activity |
const edgePosition: EdgePosition = | ||
widthOrHeight === 'width' ? EdgePositionRight : EdgePositionBottom | ||
const elementMetadata = MetadataUtils.findElementByElementPath(metadata, selectedElement) | ||
const originalFrame = elementMetadata?.globalFrame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be the localFrame instead? are we using localFrame anywhere anymore? – edit: for size currently the localFrame and globalFrame matches, currently... that is until we start adding scaling or rotation support!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth a little on this, IIRC the pre-existing code pushed me more in the direction of the global canvas frame.
editor/src/components/canvas/canvas-strategies/strategies/shared-move-strategies-helpers.ts
Show resolved
Hide resolved
...ctions/layout-section/self-layout-subsection/frame-updating-layout-section.spec.browser2.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧑🍳👌
Problem:
The new simplified layout section currently doesn't support updates for multiselection when ideally it should.
Fix:
Behind the scenes of the new layout section, changes have been implemented via delta updates at a high level. With single selection it's easy to take the current value and given a new value determine the delta and then feed that down into the inspector strategy. However that doesn't work as easily when handling multiselected elements with mixed values for the same property and would require a lot of that logic to be handled in the UI layer which also seems like the wrong approach.
In this PR that translation is handled by "direct" inspector strategies which layer over the regular delta based strategies, taking a particular value, calculating the delta and passing it into the logic previously handling the purely delta changes (at least for resizing).
Given the strategies were previously based on the deltas, this resulted in comparatively little changes as we've been able to reuse the logic, but it does seem a bit odd to have the direct value and then calculate the delta, which then calculates the direct value lower down.
Commit Details:
changeBounds
andChangeBoundsResult
toshared-absolute-resize-strategy-helpers.ts
.resizeInspectorStrategy
anddirectResizeInspectorStrategy
.getAppropriateLocalFrame
as the logic was needed/used in more than one place.getDirectMoveCommandsForSelectedElement
.startingFeatureSwitches
parameter torenderTestEditorWithCode
.originalLocalFrame
tooriginalLTWHValues
so that we can instead capture plurality of the positional/sizing properties.FrameUpdate
type to the simplified layout section to capture delta changes versus direct (where the property is set to a specific value) changes.updateFrame
callback extended to support the differing types of updates by executing differing inspector strategies.