Skip to content

Read sortable-item size from layout pixels, not the transformed rect - #698

Merged
NullVoxPopuli merged 1 commit into
adopted-ember-addons:masterfrom
gitKrystan:gitKrystan/scaled-ancestor-size
Nov 17, 2026
Merged

NullVoxPopuli merged 1 commit into
adopted-ember-addons:masterfrom
gitKrystan:gitKrystan/scaled-ancestor-size

Conversation

@gitKrystan

Copy link
Copy Markdown
Contributor

Fixes #697

What

sortable-item's width and height getters read getBoundingClientRect() (since 5.4.0). That rect is scaled by a CSS transform on an ancestor, while offsetTop, offsetLeft and the margins are not, so the drag math mixes scaled and unscaled values.

The getters now read the fractional border-box size from the computed style through a new getLayoutSize helper. It adds padding and border when box-sizing is content-box, and falls back to offsetWidth / offsetHeight when the computed size is not a number (for example auto).

This keeps fractional precision without the transform scaling.

Why the tests didn't catch it

The new test renders the list under transform: scale(0.5) with fractional item sizes and checks height and width against the layout size. The default ember-qunit container is scaled by 0.5 too, which is where downstream apps hit this.

Verification

  • The new test fails on master and passes with the change.
  • pnpm lint passes.
  • The full test-app suite is not green in my environment either way: the same 16 acceptance tests hit the 60s timeout on master and with this change. Some of them pass when run on their own. I could not tell whether that is my environment or the suite, so CI is the real check.
  • A downstream app test (a reorder test that failed after upgrading from 5.3.4 to 5.5.1 under the scaled container) passes with this change applied as a local patch, along with 18 other test files that use ember-sortable/test-support.

Drafted with Claude Code (Claude Sonnet 5.5). The verification numbers come from local runs.

getBoundingClientRect() is scaled by a CSS transform on an ancestor, but
offsetTop, offsetLeft and margins are not, so the width and height getters
mixed scaled and unscaled values. Read the fractional size from the computed
style instead, with an offset-size fallback.

Fixes adopted-ember-addons#697

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Nov 17, 2026

Copy link
Copy Markdown

👷 Deploy request for ember-sortable pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit fa5a45c

@NullVoxPopuli
NullVoxPopuli marked this pull request as ready for review November 17, 2026 14:58
@NullVoxPopuli
NullVoxPopuli merged commit fd5a414 into adopted-ember-addons:master Nov 17, 2026
18 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sortable-item width/height are scaled by a CSS transform on an ancestor (regression since 5.4.0)

2 participants