fix: Rework logic for grid ordering in hero component #1799
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.
Jira
http://vjira2:8080/browse/BDS-2079
Summary
Fixes a bug where hero
reverseOrder
prop does not work whenimageValign
isbottom
Details
I set out only to fix the original bug. However, I found the existing twig logic for
hero
to be pretty difficult to read, in part because there were a number of logic errors. For example:First, both of these statements are logically identical if you remove the second conditions (if something is "not bottom", you don't need to also check for whether it could be "top").
Digging in further, what happens if the value of
imageValign
ismiddle
? Well, both of the above statements evaluate totrue
, so you end up with image on mobile being both first and last. 馃檭So I ended up re-working a lot of the logic here. Hopefully it's equivalent to what was there before without the additional bugs.
How to test
Reproduce the bug
Change
imageValign
tobottom
View the pattern at /pattern-lab/?p=components-hero--reverse-order
Note that the image is on the right (expected on the left).
Confirm the fix