#1853: Fix direction detection for display:contents lists - #2477
Open
Yahiro025 wants to merge 1 commit into
Open
#1853: Fix direction detection for display:contents lists#2477Yahiro025 wants to merge 1 commit into
Yahiro025 wants to merge 1 commit into
Conversation
Walk past display:contents (including slotted/shadow wrappers) so flex/grid direction is taken from the layout-generating ancestor. Co-authored-by: Bennett Payoyo <Yahiro025@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1853.
Problem. Sortable on a
display: contentscontainer inside a CSS grid (especially with an incomplete last row) can place the dragged item at the end of the grid. Settingdirection: 'horizontal'or attaching Sortable to the grid itself worked around it.Root cause.
_detectDirectioninspects the sortable’s own style.display: contentshas no box; children participate in the ancestor’s grid/flex. Block children made the function returnvertical._ghostIsLastthen treated “to the right of the item union” as “after the list.”Fix. Walk past
display: contentsancestors (includingassignedSlotand a shadow host) and use that ancestor for flex/grid/width. Also treatinline-flex/inline-gridlikeflex/grid.Tests.
tests/display-contents-grid.html+ direction assertions (grid/flex-row → horizontal; flex-col/block/1-col grid → vertical; nested contents and inline-grid → horizontal). Drag item 1 onto item 3 expects2, 3, 1, 4, 5.Verification.
npm i && NODE_ENV=umd npx rollup -c ./scripts/umd-build.js && npx testcafe chrome:headless tests/Sortable.test.js --reporter spec→ 20 passed. Builds not committed.AI-assisted disclosure. Drafted with AI assistance. Root cause confirmed by
detectDirectionreturningverticalon a contents+grid fixture before the walk-up.Please merge only to
master.