Skip to content

fix(canvas): keep the selection outline on an element that is still transitioning - #559

Closed
shreyanshkotak wants to merge 2 commits into
doop-design:mainfrom
shreyanshkotak:fix/selection-outline-follows-transitions
Closed

shreyanshkotak wants to merge 2 commits into
doop-design:mainfrom
shreyanshkotak:fix/selection-outline-follows-transitions

Conversation

@shreyanshkotak

Copy link
Copy Markdown
Contributor

Fixes #558

Why

When a prop change on a selected instance changes its size, and the component has transition: all (as the Button kit does), the selection outline and W × H badge stayed at a size the element never settled at, until it was picked again.

The outline follows its element by asking the frame runtime for the element's box on every html update, and the runtime measured once. That measurement landed while the padding was still transitioning.

What changes

  • doop:locate in the frame runtime (src/lib/frameRuntime.ts) still answers straight away, then answers again as each running transition or animation ends, or when a loading font is in (whenLayoutSettles):
    • at most once a frame;
    • each one is waited for on its own, so a long animation elsewhere in the frame doesn't hold the outline back;
    • endless and zero-rate animations are skipped, since they never finish;
    • only the latest locate per request id answers again, and an id is dropped once its waits are over.
  • The selection outline, multi-pick outlines, comment pins and layer-hover outline all use this locate, so they all follow. The layer-hover handler in FrameView.tsx now drops a late reply for a row the pointer has left, as the selection handler already did.
  • .context/TECHSTACK.md describes the behaviour.

Not covered

Size changes that come from a linked stylesheet's web font or an unsized image loading after the update. The runtime already reports those loads (doop:frame-updated), so a re-locate on that message would be a small follow-up.

Tests

  • New case in tests/elementResizeBrowser.test.ts: a button under transition: all 400ms changes variant while selected, beside an endless spinner and a 10s animation, and the grips must reach the settled width. It fails on main (stuck at 124 instead of 152).
  • The 10 browser and Layers test files that place outlines, pins and grips pass (208 tests).
  • typecheck, lint, format:check and doc-lint pass. The full suite passes except tests/serverListen.test.ts, which fails the same way on an untouched main on my machine.

…ransitioning

The outline follows its element by asking the frame runtime for its box on
every html update, and the runtime measured once. A prop change on an
instance whose component has `transition: all` landed while the padding was
still on its way, so the outline and size badge stayed at that in-between
size until the element was picked again.

The runtime now answers a locate straight away and, when finite transitions
or animations are running or a font is loading, once more after they settle.
Only the latest locate per request id answers again. Comment pins and hover
outlines use the same locate, so they follow too.

Fixes doop-design#558
Review follow-ups on the selection outline fix:

- answer a locate again as each running transition or animation ends (at
  most once a frame), so a long animation elsewhere in the frame no longer
  holds the outline at its mid-transition size; skip zero-rate animations,
  whose finished promise never settles
- keep a locate's turn only while it waits, so the map of request ids does
  not grow with every pin and pick
- drop a late layer-hover reply for a row the pointer has left
- the regression test also runs a spinner and a 10s animation beside the
  button, waits out the reset's own transition, and takes the file's timeout
@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR refreshes element outlines after running transitions, finite animations, and loading fonts finish.

  • Editor outlines and pins follow elements as their motion settles.

Deferred scope: shreyanshkotak explicitly leaves size changes from later-loading linked stylesheets, web fonts, and unsized images for a follow-up.

Diagram

sequenceDiagram
  participant Parent as FrameView
  participant Runtime as Frame runtime
  participant Browser
  Parent->>Runtime: doop:locate(id, selector)
  Runtime-->>Parent: Current box
  Runtime->>Browser: Wait for running animations and loading fonts
  Browser-->>Runtime: One wait ends
  Runtime->>Runtime: Check that request is still latest
  Runtime-->>Parent: Fresh box on next frame
  Parent->>Parent: Drop layer-hover reply if row changed
Loading

Reviews (1) · Last reviewed commit: "fix(canvas): re-locate as each animation..." · Reviewed by Greptile

VTalleyrand pushed a commit to VTalleyrand/doop that referenced this pull request Nov 20, 2026
…ks don't flicker (doop-design#559)

* fix(canvas): let a root vector's stroke spill past its box, as in Figma

A standalone shape is its own iframe, sized exactly to the frame, so a
stroke wider than the path's padding was cut off at the box. The runtime now
asks for a margin that holds its widest stroke (doop:bleed-want); FrameView
grows the iframe by it on every side, stops clipping the surface, and the
runtime insets its body once told (doop:bleed). The runtime keeps speaking
in the frame's design px, translating only at its viewport APIs, and the
three editor sites that measure the iframe element take the margin off.
Drawn path svgs paint their own overflow. W/H stay the path's geometry.

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

* fix(canvas): pick and drag a sibling inside an entered standalone group

In a standalone shape, every hit collapsed to the shape's root, so with a
layer inside it picked, clicking a sibling kept the old pick through the
click's 250ms probe and then landed on the whole group: picked, dropped,
picked. The press also dragged the whole shell. Once a layer inside the
standalone is picked, hits resolve at that level (as groupLevel does in a
frame) and the press goes through the layer move, picking the sibling at
once; a press on the root itself still drags the shell.

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

* fix(canvas): the bleed margin's wrapper takes no presses either

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

* fix(canvas): hold a miter join out to its own miter limit

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d14f97012f710aa7426752a8a3c4d873da792176)
@kgoedecke

Copy link
Copy Markdown
Collaborator

I think the better option is to not have transitions when an element is being edited, I made a PR here: #564

Closing this for now.

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.

Selection outline keeps a stale size after a prop change resizes an instance

2 participants