Skip to content

fix(studio): a rotate keeps a transform-centred element in place - #4826

Merged
miguel-heygen merged 1 commit into
fix/studio-rotate-none-dropfrom
fix/studio-rotate-transform-centred
Oct 1, 2026
Merged

miguel-heygen merged 1 commit into
fix/studio-rotate-none-dropfrom
fix/studio-rotate-transform-centred

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Rotating an element centred with transform: translate(-50%, -50%) (the common centring idiom) keeps it in place, while dragging and after the save.

The CSS rotate property applies before transform, so a turn written there also turns the transform's translate: the box swung around its old centre (62 px on the bench's centred box) and, with the plain-CSS rotate save, stayed there. Now, when the element's transform translates it, the turn is written into that transform after the translate (translate(-50%, -50%) rotate(25deg)), which turns the box about its visual centre. A second rotate replaces its own trailing rotate() instead of stacking one. The CSS rotate property is still the target for every element whose transform does not move it. Where the turn goes is read once at press, so the draft does no per-frame style read; the save writes the same value the draft drew.

The authored transform is read from the inline style, else from the last matching stylesheet rule (specificity, !important and @media are not weighed; noted in the code).

Stacked on #4802.

Score (edit accuracy bench with the transform-centred rotate rows from #4801, ^rotate-none-transform-, 4 cases, same machine)

all but smoothness teleport (worst swing while dragging) drop
#4802 (before) 0/4 0/4, 62.4 px 4/4
this branch (after) 4/4 4/4, 0.0 px 4/4

Tests

  • manualOffsetDrag.test.ts: a transform-centred element with an authored rotate: 30deg turns inside its transform after the translate, leaves the rotate property alone, and a second turn replaces the first.
  • plainRotation.test.ts: the save patches the transform as drawn, and a failed save puts the inline transform back.
  • Each fails with its fix reverted (never taking the transform path, appending instead of replacing, not restoring the transform).

Before

A transform-centred box after a 25 deg turn: swung off its centre.

before

After

The same case turns in place.

after

@miguel-heygen
miguel-heygen force-pushed the fix/studio-rotate-none-drop branch from 75e080f to 216a2eb Compare October 1, 2026 01:53
@miguel-heygen
miguel-heygen force-pushed the fix/studio-rotate-transform-centred branch from d76dde8 to 0fca73b Compare October 1, 2026 02:02
@miguel-heygen
miguel-heygen merged commit 0fca73b into fix/studio-rotate-none-drop Oct 1, 2026
10 of 14 checks passed
@miguel-heygen
miguel-heygen deleted the fix/studio-rotate-transform-centred branch October 1, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant