gestalt icon indicating copy to clipboard operation
gestalt copied to clipboard

Masonry: Remove heights cache

Open liuyenwei opened this issue 9 months ago • 2 comments

Summary

Currently, we have a heightCache that is only used for the defaultTwoColumnModuleLayout. This PR makes two changes around this:

  • it removes the height cache completely
  • it updates the initial height calculation for the defaultTwoColumnModuleLayout to account for multi-column items. Currently it only supports 1-2 column items.

I honestly cannot remember why height cache was originally added when two column support was first deployed but taking a closer, there isn't any reason we specifically need to do this just for the two column layout given given that the calculation is cheap.

More specifically, my motivation for deleting this is because it introduces a strange edge case when we reflow the grid because:

  • the measurement cache, position caches are externally cache
  • we clear the measurement and position caches, but not the height store.

I initially thought of just clearing the height cache on reflow but after doing some investigation, decided just to remove this to simplify things.

liuyenwei avatar Apr 30 '24 04:04 liuyenwei

Deploy Preview for gestalt ready!

Built without sensitive environment variables

Name Link
Latest commit 3e305e86be17d13e2105801bedf44457182eac7e
Latest deploy log https://app.netlify.com/sites/gestalt/deploys/6632c526863f3400084dc74e
Deploy Preview https://deploy-preview-3544--gestalt.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Apr 30 '24 04:04 netlify[bot]

Could you also update the initializeHeightsArray function to handle the multi column width correctly? Previously I didn't do it because this code was not triggered on my testing, I was going to ask you about that.

updated!

liuyenwei avatar May 01 '24 00:05 liuyenwei