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

Tiny layout shift (SSR) #295

Closed
damaafer opened this issue Feb 12, 2024 · 1 comment
Closed

Tiny layout shift (SSR) #295

damaafer opened this issue Feb 12, 2024 · 1 comment

Comments

@damaafer
Copy link

damaafer commented Feb 12, 2024

I experiment a tiny layout shift (tenth of a percent) after hydration.

On the server, and during the first render on the client, Panes flex-grow are set with defaultSize:

On consecutive renders, Panes flex-grow are set with size.toPrecision(precision)

The difference between the raw size and the rounded one cause a tiny layout shift just after hydration. (eg. flex-grow:64.3238875877 becomes flex-grow:64.3).

Is it possible to apply same constraints on defaultSize than on size to prevent this?

Possible user workaround: store rounded sizes[] in cookie/backend instead of the raw one.

  const onLayout = (sizes: number[]) => {
    const roundedSizes = sizes.map(s => Number(s.toPrecision(3)));
    ...
  };
@bvaughn
Copy link
Owner

bvaughn commented Feb 13, 2024

Hopefully fixed in a45ab6c; published in 2.0.7


❤️ → ☕ givebrian.coffee

@bvaughn bvaughn closed this as completed Feb 13, 2024
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

No branches or pull requests

2 participants