Remove unnecessary color attributes from navigation block #18540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To have a text color setting in the navigation block, we relied on four color attributes. In other blocks, we only use two attributes. I think we had some redundancy in the attributes.
We also used some inline styles even when a user selects a preset color; this may colors not work as expected when switching the color associated with a given class.
This PR also tries to simplify the code by relying on when the new useColors hook. I noticed that I needed to fix a small thing in useColors and that change is here for testing purposes, but we should merge it in a different PR.
It also solves some bugs:
<!-- wp:navigation-menu {"textColorCSSClass":null} -->
. This pollutes the markup and is unnecessary.Description
How has this been tested?
I created multiple navigation blocks.
In some, I chose a preset color; in other, I picked a named color (at least one had accent color on 2020 theme).
I verified both blocks look as expected on the frontend and backend.
I changed the accent color on the customizer and verified the blocks correctly reflected the new color, including on the color indicator.