Skip to content

A colour typed in the Hex field stays with the node it was typed for - #663

Merged
MerciHanrim merged 1 commit into
mainfrom
accent-hex-draft-per-selection
Nov 24, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
accent-hex-draft-per-selection

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #615 (item 3).

What was wrong

The Inspector's Colour ▸ Hex field kept its draft and its error as local state, and nothing reset them when the selection changed.

  • Display: an invalid draft (#zz12) and its message "Not a colour. Use three or six hex digits, such as #336699." showed for every node selected next, and again on returning to the first node. Nothing was written.
  • Document: a valid draft not yet applied could be written to the wrong node. On node A, type #333333 without Enter, then Shift+click node B on the canvas: the selection moves to B while the Hex field keeps the focus, and the field still shows #333333. Tab then writes #333333 to B (autosaved, one Undo entry); A is unchanged. Measured on main 3864ce9a through the real UI.
  • Other paths measured on main: a plain canvas click, a Pan-mode tap and a region-select box all take the focus out of the field before the selection changes, so the draft goes to A (right). Ctrl+Z inside the field is the browser's own text undo and changes no selection.

The change

AccentField stores the draft with the key of the targets it was typed for (node ids and edge ids).

  • When the targets change, the draft and its error are dropped, as Escape drops them: they are not shown for the new targets.
  • Enter and blur apply only a draft whose key matches the current targets, so a draft started on A can never be written to B, whether the field keeps the focus or not.
  • Enter and blur on the same targets, and a canvas click that leaves the field first, behave as before.

docs/flow-colour-and-compact-nodes.md FC-5 states the rule; its test list names the new tests.

Tests

New e2e/flow-colour.spec.ts describe "the Hex draft is dropped when the selection changes (#615 item 3)":

  1. An invalid draft and its error are gone for B (canvas click) and again for A on return; no colour written.
  2. Real path: Shift+click on B keeps the focus in the field (asserted); the field shows B's value right after the selection change, and after Tab neither A nor B has a colour and Undo is unchanged.
  3. Store-driven defensive test: the selection changed through the store alone with the focus kept; Enter, then Tab, write nothing.
  4. Controls: a confirmed colour is written with one Undo entry; a canvas click after an unconfirmed draft writes it to A, not B.

On main's AccentField, tests 1–3 fail and test 4 passes. Each of the three fails at its first display check (#zz12, #333333, #123456 still in the field for B), so the write checks after it were not reached on main; the wrong write itself was measured by the reproduction probe before the tests were written.

On this branch, --workers=1 --retries=0:

  • e2e/flow-colour.spec.ts and e2e/flow-colour-views.spec.ts (chromium): 28 passed.
  • e2e/flow-colour-visual.spec.ts (chromium): 5 passed, snapshots compared.
  • e2e/flow-colour-mobile.spec.ts (mobile): 3 passed.

Every check:* script, tsc -b, lint (88 warnings, the baseline, none in AccentField) and vitest run (5758 passed) pass.

The Inspector's Hex draft and its error now belong to the colour targets they were typed for. When the targets change, an unconfirmed draft is dropped, as Escape drops it: it is not shown for the new targets, and a later Enter or blur cannot apply it to them, even while the field keeps the focus (a Shift+click on the canvas does). Enter and blur still apply a draft to its own targets, and a canvas click still leaves the field first, so the draft goes to the node it was typed for.

Part of #615
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 24, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: e633aa2
Status: ✅  Deploy successful!
Preview URL: https://e4d9bcea.cozy-loop-studio.pages.dev
Branch Preview URL: https://accent-hex-draft-per-selecti.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit 4e5ec44 into main Nov 24, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the accent-hex-draft-per-selection branch November 24, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant