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

GridMeasurementHelper component to continuously measure grid cells #6517

Merged
merged 26 commits into from
Oct 15, 2024

Conversation

gbalint
Copy link
Contributor

@gbalint gbalint commented Oct 10, 2024

Problem:
When you reparent from a grid to another grid, for a single frame the element blinks at the same cell position as it was in the original grid: https://screenshot.click/09-31-10wrd-ysw94.mp4

Root cause:
As you hover over the target grid, the grid-reparent-strategy is selected. It triggers a showGridControl command, so the grid control is shown and the cells can be measured. However, it won't be able to position to the real target cell in this frame yet, because the control is not enabled yet, so we don't have the cell bounds in the metadata.

Fix:
Instead of using grid controls to measure let show permanent grid measurement helpers so grids can always be measured.

Commit Details: (< vv pls delete this section if's not relevant)

  • Added memoized function getAllGrids which returns all the grids from the metadata
  • Added GridMeasurementHelper component which renders a grid with placeholder divs in its cells (similarly to GridControl, but much-much simpler)
  • Rendering GridMeasurementHelper for all grids
  • Use rendered grid measurement helpers in dom-walker to measure the size of grid cell bounds
  • Remove all the hacks (most notably getMetadataWithGridCellBounds) which made it possible to use latestMetadata in interaction when startingMetadata did not include grid cell bounds. This is not needed anymore, because the grid cells are always measured using the always-on GridMeasurementHelper components

Manual Tests:
I hereby swear that:

  • I opened a hydrogen project and it loaded
  • I could navigate to various routes in Play mode

Copy link
Contributor

github-actions bot commented Oct 10, 2024

Try me

Copy link

relativeci bot commented Oct 10, 2024

#14793 Bundle Size — 57.96MiB (~+0.01%).

360a854(current) vs 916e8b9 master#14786(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#14793
     Baseline
#14786
Regression  Initial JS 40.95MiB(~+0.01%) 40.94MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 17.97% 17.85%
No change  Chunks 20 20
No change  Assets 22 22
No change  Modules 4148 4148
No change  Duplicate Modules 213 213
No change  Duplicate Code 27.34% 27.34%
No change  Packages 477 477
No change  Duplicate Packages 70 70
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#14793
     Baseline
#14786
Regression  JS 57.95MiB (~+0.01%) 57.95MiB
Improvement  HTML 7.37KiB (-0.25%) 7.39KiB

Bundle analysis reportBranch fix/reparent-blinkingProject dashboard


Generated by RelativeCIDocumentationReport issue

@gbalint gbalint marked this pull request as ready for review October 10, 2024 16:31
@gbalint gbalint marked this pull request as draft October 10, 2024 17:01
@gbalint gbalint marked this pull request as ready for review October 11, 2024 08:50
@gbalint gbalint marked this pull request as draft October 14, 2024 10:56
@gbalint gbalint changed the title Show invisible grid controls on all grids during interactions GridMeasurementHelper component to continuously measure grid cells Oct 14, 2024
Copy link
Contributor

Try me

(building...)

Copy link
Contributor

Try me

(deploying...)

Copy link
Contributor

Try me

@gbalint gbalint marked this pull request as ready for review October 14, 2024 16:08
@gbalint gbalint marked this pull request as draft October 15, 2024 11:54
@gbalint gbalint marked this pull request as ready for review October 15, 2024 14:44
@gbalint gbalint merged commit 66fc4c8 into master Oct 15, 2024
13 checks passed
@gbalint gbalint deleted the fix/reparent-blinking branch October 15, 2024 15:31
liady pushed a commit that referenced this pull request Dec 13, 2024
…6517)

**Problem:**
When you reparent from a grid to another grid, for a single frame the
element blinks at the same cell position as it was in the original grid:
https://screenshot.click/09-31-10wrd-ysw94.mp4

**Root cause:**
As you hover over the target grid, the grid-reparent-strategy is
selected. It triggers a showGridControl command, so the grid control is
shown and the cells can be measured. However, it won't be able to
position to the real target cell in this frame yet, because the control
is not enabled yet, so we don't have the cell bounds in the metadata.

**Fix:**
Instead of using grid controls to measure let show permanent grid
measurement helpers so grids can always be measured.

**Commit Details:** (< vv pls delete this section if's not relevant)

- Added memoized function `getAllGrids` which returns all the grids from
the metadata
- Added `GridMeasurementHelper` component which renders a grid with
placeholder divs in its cells (similarly to `GridControl`, but much-much
simpler)
- Rendering `GridMeasurementHelper` for all grids
- Use rendered grid measurement helpers in dom-walker to measure the
size of grid cell bounds
- Remove all the hacks (most notably `getMetadataWithGridCellBounds`)
which made it possible to use latestMetadata in interaction when
startingMetadata did not include grid cell bounds. This is not needed
anymore, because the grid cells are always measured using the always-on
`GridMeasurementHelper` components

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode
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