Hydration bugs that were really design bugs

Priya Raman

Frontend Engineer · Pune

  • May 22, 2024
  • 2 min read
  • 11
Hydration bugs that were really design bugs

When a flash of wrong content traced back to an undecided empty state. Good frontend engineering in a design system mostly looks like removing things.

The component that started it

Moving decisions from JavaScript into CSS made the components easier to reason about. The stylesheet now owns layout, and the script owns behaviour, which sounds obvious until you count how often we had crossed that line.

Plate 1 from the "Hydration bugs that were really design bugs" galleryPlate 2 from the "Hydration bugs that were really design bugs" galleryPlate 3 from the "Hydration bugs that were really design bugs" galleryPlate 4 from the "Hydration bugs that were really design bugs" galleryPlate 5 from the "Hydration bugs that were really design bugs" galleryPlate 6 from the "Hydration bugs that were really design bugs" gallery
The view that got us through a long release week.

Testing what the user sees

The token build runs on every merge and publishes a versioned package. Nobody has to remember to run it, which is the only kind of build step that survives a busy quarter.

  • Delete dead CSS every sprint
  • Let components respond to their container
  • Keep layout in CSS and behaviour in JavaScript
  • Version the token package on every merge

Numbers after three months

We replaced most snapshot tests with a handful of visual checks at three container widths. Failures now show a picture of the problem instead of a two-hundred-line diff of class names.

The card component had four layout props and eleven media queries. Rewriting it with container queries left one prop and three rules, and the tests finally described what the card did instead of which breakpoint it was in.

As always, the files and notes behind this piece are in the studio archive. Ask and we will share what we can.

Next time we will bring the numbers from the following quarter and see whether any of this held up outside the studio.

None of this is finished. We will keep adjusting as the product changes, and we will write it down here when something breaks in an interesting way.


Found this useful?

Priya Raman

About the author

Priya Raman

Frontend Engineer · Pune

Priya builds the component library and the token pipeline behind it. She is happiest deleting CSS and writing small tools that make reviews shorter.

Related dispatches

All posts

11 comments

Leave a comment

Already have an account? Log in

Your email is never shown.

  • Chiara Bianchi

    May 25, 2024

    Would love a follow-up on how the team felt about the change after six months.

  • Rafael Costa

    Author's pick May 27, 2024

    Curious how this holds up on low-end Android devices. That is where most of our users are.

  • Kwame Mensah

    May 31, 2024

    How long did the whole migration take, start to finish?

  • Jules Martin

    Jun 4, 2024

    Would love a follow-up on how the team felt about the change after six months.

    Priya Raman

    Author Jun 6, 2024

    We are planning a follow-up after the next release. I will link it here.

    Diego Morales

    Jun 9, 2024

    Good question. I would guess it depends on how many teams consume the system.

  • Aiko Tanaka

    Jun 5, 2024

    The screenshots in the gallery helped a lot. Seeing the before and after side by side made it click.

  • Marcus Chen

    Jun 9, 2024

    Printed this out for the studio wall. Old habits.

    Priya Raman

    Author Jun 9, 2024

    Roughly six weeks, most of it spent on communication rather than code.

    Arjun Mehta

    Jun 14, 2024

    Same here. The second attempt went much better once we wrote the rules down first.

  • Tomasz Nowak

    Jun 11, 2024

    Curious how this holds up on low-end Android devices. That is where most of our users are.

Previous

Dark mode is not an inverted light mode

Next

Frame by frame: rebuilding a loading state