Skip to content

fix(reorder-group): use exact item heights - #31710

Open
officialasishkumar wants to merge 1 commit into
ionic-team:mainfrom
officialasishkumar:fix/reorder-group-fractional-heights
Open

officialasishkumar wants to merge 1 commit into
ionic-team:mainfrom
officialasishkumar:fix/reorder-group-fractional-heights

Conversation

@officialasishkumar

Copy link
Copy Markdown

Issue number: resolves #31670


What is the current behavior?

When a drag starts, ion-reorder-group works out where each row ends by adding up each item's offsetHeight. That value is rounded to a whole number, so items with a fractional height add an error for every row and the swap point drifts further from the item boundary further down the list.

Items that make room for the dragged item are also moved by its rounded height, so they land slightly off their target row.

What is the new behavior?

  • The swap boundaries are computed from each item's getBoundingClientRect() height, so they line up with the items at every position in the list.
  • Displaced items move by the exact height of the selected item.
  • Added e2e tests covering both behaviors.

Does this introduce a breaking change?

  • Yes
  • No

Other information

The new tests use 30 rows of 20.5px. Without the fix, they fail in Chromium, Firefox and WebKit: dragging to the center of row 25 reports to: 24, and the displaced rows move by 21px rather than 20.5px. With the fix, they pass in all three, along with the rest of the reorder-group e2e tests.

getBoundingClientRect() reflects transforms on ancestors, unlike offsetHeight. This matches the pointer position and containerTop, which are already in viewport coordinates.

Compute the swap boundaries from each item's getBoundingClientRect
height rather than offsetHeight. offsetHeight is rounded to a whole
number, so summing it added an error for every item with a fractional
height. The swap point moved further from the item boundary further
down the list, by about 31px at row 62 with 65.5px items.

Move the displaced items by the exact height of the selected item as
well, so they land on the row they are making room for.

closes ionic-team#31670
@officialasishkumar
officialasishkumar requested a review from a team as a code owner November 7, 2026 06:34
@vercel

vercel Bot commented Nov 7, 2026

Copy link
Copy Markdown

@officialasishkumar is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: reorder swap boundaries drift with fractional row heights

1 participant