Skip to content
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

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

seanparsons
Copy link
Contributor

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:

  • 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.

- 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.
@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2023

Try me

@relativeci
Copy link

relativeci bot commented Oct 16, 2023

Job #8693: Bundle Size — 63.29MiB (+0.02%).

01dd602(current) vs 5957b21 master#8689(baseline)

Warning

Bundle contains 64 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
Job #8693
     Baseline
Job #8689
Regression  Initial JS 35.57MiB(+0.03%) 35.56MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 19.54% 18.9%
No change  Chunks 28 28
No change  Assets 32 32
No change  Modules 4014 4014
No change  Duplicate Modules 455 455
No change  Duplicate Code 31.36% 31.36%
No change  Packages 409 409
No change  Duplicate Packages 64 64
Bundle size by type  Change 1 change Regression 1 regression
                 Current
Job #8693
     Baseline
Job #8689
Regression  JS 63.28MiB (+0.02%) 63.27MiB
Not changed  HTML 11.54KiB 11.54KiB

View job #8693 reportView feature/multiselect-layout-pins-... branch activity

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2023

Performance test results:
(Chart1)
(Chart2)

const edgePosition: EdgePosition =
widthOrHeight === 'width' ? EdgePositionRight : EdgePositionBottom
const elementMetadata = MetadataUtils.findElementByElementPath(metadata, selectedElement)
const originalFrame = elementMetadata?.globalFrame
Copy link
Contributor

@balazsbajorics balazsbajorics Oct 16, 2023

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!

Copy link
Contributor Author

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.

Copy link
Contributor

@balazsbajorics balazsbajorics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧑‍🍳👌

@seanparsons seanparsons merged commit ae4c83a into master Oct 17, 2023
3 checks passed
@seanparsons seanparsons deleted the feature/multiselect-layout-pins-update branch October 17, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants