Adjust flex item position to account for reversal when laying out unconstrained #13936
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.
Description of Change
Like most of Flex, RowReverse/ColumnReverse don't make of a ton of sense when measuring/laying out in unconstrained directions. The implementation of reverse calls for starting at the far edge and laying out in reverse order; when the direction is unconstrained, "far edge" has no meaning. The current implementation treats the unconstrained "far edge" as zero; this means that the reversed items are starting at zero and laying out into negative X,Y positions.
The best option in the absence of a known constraint is to lay out in reverse order from the near edge; the width of the unconstrained container is just the width of the flex items within it. Since the implementation is already almost doing this, we just do a final pass to adjust the positions of the items into positive X,Y positions.
Draft for now; this needs unit tests.
Issues Fixed
Fixes #7756