-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move normalization step into the dispatch flow (#6549)
https://github.com/user-attachments/assets/d184b155-e18a-42d6-ba84-1532f6ebd280 ## Problem The tailwind style plugin can't differentiate between a prop being removed from the inline style prop, and that prop never having been there at all. For example, when a flex gap is removed by dragging it in the negative direction, it goes from positive -> 0 -> being removed from the style prop. When the normalisation step kicks in, there's no gap prop in the inline style, so the tailwind plugin doesn't do anything. To make matters worse, when the gap property is removed while the interaction is in progress, the value coming from the generated tailwind class takes precedence, so the flex gap jumps back to its original size. ## Fix The problem of removing props in the normalization step is fixed by 1. moving the normalization step in the display flow 2. making the normalization step aware that some props need to be removed 3. find out which elements to normalize/which props to remove from the dispatched actions and the strategies, and running the normalization on those elements and prop. The problem of prevent the CSS classes to kick in when a prop is removed (for example, when the inline `gap` prop is removed in the flex gap strategy), this PR adds a postprocessing step alongside the normalization step, that patches an allowlisted set of props to a "zero" value, which simulates the prop not being there at all ### Details - added a test for removing the gap prop set from Tailwind - added a `propertiesToRemove` param to `normalizeFromInlineStyle`, and updated the tailwind style plugin to use that prop to remove classes from the `className` prop - added the code that finds out which elements/props to normalize from the dispatched actions - added the code that finds out which elements/props to normalize from the strategies, and that tells which elements to patch during an interaction **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 Fixes #[ticket_number] (<< pls delete this line if it's not relevant)
- Loading branch information
Showing
7 changed files
with
347 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.