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

Only set width/height on zero-size element conversion #4351

Merged
merged 7 commits into from
Oct 13, 2023

Conversation

bkrmendy
Copy link
Contributor

@bkrmendy bkrmendy commented Oct 10, 2023

Problem

When double-clicking the zero-sized element control on an element that is in a flex parent and has position: absolute set, the flexBasis prop is not taken into account, and the element stays zero-sized on one axis.

FIx

The logic doing the conversion is refactored into two inspector strategies:

  1. Convert flex child to non-zero frame
    • applied when the element is in a flex context
    • flex, flexShrink, flexGrow and flexBasis are pruned so they don't interfere with sizing
    • width: 100, height: 100 is added
  2. Convert element to non-zero frame
    • width: 100, height: 100 is added
    • if the element is inline, display: inline-block is added

@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2023

Try me

@relativeci
Copy link

relativeci bot commented Oct 10, 2023

Job #8623: Bundle Size — 63.27MiB (~-0.01%).

e48f6c8(current) vs 5957b21 master#8614(baseline)

Warning

Bundle contains 64 duplicate packages – View duplicate packages

Bundle metrics  Change 1 change Improvement 1 improvement
                 Current
Job #8623
     Baseline
Job #8614
Improvement  Initial JS 35.56MiB(~-0.01%) 35.56MiB
No change  Initial CSS 0B 0B
No change  Cache Invalidation 19.53% 19.53%
No change  Chunks 28 28
No change  Assets 32 32
No change  Modules 4016 4016
No change  Duplicate Modules 456 456
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 Improvement 1 improvement
                 Current
Job #8623
     Baseline
Job #8614
Improvement  JS 63.26MiB (~-0.01%) 63.26MiB
Not changed  HTML 11.54KiB 11.54KiB

View job #8623 reportView fix/zero-sized-element-remove-ab... branch activity

@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2023

Performance test results:
(Chart1)
(Chart2)

@bkrmendy bkrmendy changed the title Remove absolute positioning props on zero-size element conversion Only set width/height on zero-size element conversion Oct 11, 2023
@bkrmendy bkrmendy marked this pull request as ready for review October 11, 2023 11:07
function maybeAddDisplayInlineBlockCommands(
element: ElementInstanceMetadata,
): Array<CanvasCommand> {
if (isIntrinsicallyInlineElement(element)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe flip the logic here for an early return or a ternary return

Copy link
Contributor

@Rheeseyb Rheeseyb left a comment

Choose a reason for hiding this comment

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

This looks good, but please hold off on merging until #4360 is complete, as that includes a refactoring of a function sizeToDimensionsFromFrame that it would make sense to use here.

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.

the new code reads so much better!

@bkrmendy bkrmendy merged commit 1ea7e5a into master Oct 13, 2023
9 checks passed
@bkrmendy bkrmendy deleted the fix/zero-sized-element-remove-absolute-props branch October 13, 2023 08:37
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.

4 participants