Skip to content

Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.

fix(v0.11.7): QA close-out — deselect, render-phase writes, honest share docs

Ashiq Hussain Mir97826ecf8367
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b46918d..e5a91fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,58 @@
All notable changes to Canvix will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
+## [0.11.7] — 2026-11-01
+
+The three findings that stayed open after the v0.11.4–v0.11.6 QA sweep
+(§5.2 of `research/V0114-QA-PASS.md`): one interaction gap, one React
+anti-pattern, one documentation debt.
+
+### Fixed
++- **Ruler→guide initial position used the wrong coordinate** (found while
++ verifying the guide fix): `rulers.tsx beginGuide()` computed the seed
++ position from the swapped axis — mouse X for a horizontal guide, mouse
++ Y for a vertical one. Mid-drag the first mousemove masked it, but a
++ bare ruler click committed a guide at a nonsense position and the
++ dashed draft flashed one frame in the wrong place.
+ - **F1 — no deselect on empty-canvas click.** Clicking empty canvas kept
+ the current selection; only Escape (and touch) deselected. A bare click
+ is a zero-size marquee, and `selectInMarquee` now clears the selection
+ for it — Canva parity (`research/V0117-QA-FOLLOWUPS.md`).
+- **F5 — React render-phase update warning.** Console:
+ "Cannot update a component (`MagicLayersDialog`/`TopBar`) while
+ rendering a different component (`CanvasStage`)". Three store writes
+ lived inside `setState` updaters — the draw-stroke commit
+ (`addElement` inside `setDraft`), the marquee select
+ (`setSelection`/`clearSelection` inside `setMarquee`) and the ruler
+ guide drop (`addManualGuide` inside `setDraftGuide`). Updaters run
+ during render, so each write synchronously re-rendered other
+ components mid-render (which component the warning names depends on
+ subscriber order — hence the misleading "MagicLayers" attribution).
+ All three now commit at event time, outside any updater, with local
+ mirrors (`marqueeShapeRef`, the stroke `points`, the guide `position`)
+ keeping the gesture data exact. Amusingly, F1 had been masking the
+ marquee variant: a bare click early-returned before any store write.
+- **F6 — Share dialog documented the wrong access model.** The dialog
+ offered a decorative Only me / Anyone with the link / Public selector
+ that nothing enforced ("Public — listed in the community gallery"
+ described a gallery that does not exist). It now documents the rules
+ the server actually enforces (`src/lib/auth/design-guard.ts`):
+ anyone who can reach the instance can open the link; ownerless
+ designs (created signed-out) stay link-editable; owned designs open
+ read-only for everyone else (view-only banner, 403 on saves); there is
+ no cloud gatekeeping — reachability is decided by the deployment. When
+ you are viewing someone else's design, the dialog says so.
+
+### Changed
+- `ShareDialog` no longer reads/writes the `canvix:share:<id>`
+ localStorage preference (the old decorative selector's storage).
+
+### Added
+- Playwright `qa-followups.spec.ts` (5 tests): the F1 deselect click
+ (plus re-select of the element), the marquee re-select and
+ empty-marquee clear, stroke draw and ruler-guide drop with zero
+ render-phase warnings, and the F6 access-model documentation.
+
## [0.11.6] — 2026-11-01
Two QA-pass findings in panel state hygiene (§5.2 of
diff --git a/README.md b/README.md
index 64d1518..def50bb 100644
--- a/README.md
+++ b/README.md
@@ -221,6 +221,11 @@ is right here.
gap-free catch-up after disconnects. Architecture: an append-only event log in
Postgres + server-sent events downstream + batched op POSTs upstream — works on
Vercel serverless and self-hosted Node alike, no WebSocket server required.
+ **Link access (documented in the Share dialog since v0.11.7):** anyone who
+ can reach your instance can open a share link; ownerless designs (created
+ while signed out) are editable by everyone with the link, while designs
+ owned by an account open read-only for everyone else — there is no cloud
+ gatekeeping, reachability is decided by your deployment.
Optimistic local edits always keep the canvas butter-smooth. Since **v0.10**
collaboration is also **offline-safe**: edits made while disconnected (or
after a crash/reload) queue in IndexedDB and merge deterministically on
@@ -749,6 +754,11 @@ tool descriptions so agents pick the right format.
stale 6-of-42 grid), web search without an AI provider says so, and
the top-bar mode control + Tools-panel Draw toggle always agree
*(v0.11.6)*
+- [x] QA sweep close-out — empty-canvas click deselects (Canva parity),
+ zero render-phase store writes in canvas gestures (the
+ “Cannot update a component while rendering” warning, root-caused to
+ stroke/marquee/guide commits — not Magic Layers), and the Share
+ dialog documents the real access model for self-hosters *(v0.11.7)*
- [ ] Plugin system (external, installable apps) — sandboxed-iframe MVP
per `research/PLUGIN-SYSTEM.md`: manifest + permission model, iframe
sandbox with postMessage bridge, an “Apps” panel store, and 2–3
diff --git a/package.json b/package.json
index 6f4caf1..068c0b4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "canvix",
- "version": "0.11.6",
+ "version": "0.11.7",
"private": false,
"description": "Canvix — free & open-source graphic design tool. A community-built Canva alternative.",
"scripts": {
diff --git a/research/V0114-QA-PASS.md b/research/V0114-QA-PASS.md
index a46b04c..dbdac27 100644
--- a/research/V0114-QA-PASS.md
+++ b/research/V0114-QA-PASS.md
@@ -44,6 +44,9 @@ share → auth → collaboration → comments → versions → mobile.
the current selection; only Escape deselects. Canva deselects on empty
click. One-line fix in `CanvasStage.handleStageMouseDown` (stage-level
click that hits no element → clear `selectedIds`).
+ **→ FIXED in v0.11.7** (a bare click is a zero-size marquee, and
+ `selectInMarquee` now clears the selection for it;
+ `research/V0117-QA-FOLLOWUPS.md`).
- **F2 — Photos panel search state sticks.** After a web search returns
“Web results (0)”, the “All photos” tab shows only the last category’s
photos (6 of 42) instead of the full grid; the panel must be closed and
@@ -77,10 +80,19 @@ share → auth → collaboration → comments → versions → mobile.
component (`MagicLayersDialog`) while rendering a different component
(`CanvasStage`)”. A setState-during-render in the MagicLayers flow —
harmless today but a future-interaction landmine.
+ **→ FIXED in v0.11.7** (never a MagicLayers bug: three gesture commits —
+ stroke, marquee, ruler-guide — wrote the store inside `setState`
+ updaters, which run mid-render; all three now commit at event time.
+ The named component varies by subscriber order;
+ `research/V0117-QA-FOLLOWUPS.md`).
- **F6 — share of signed-out ownerless designs.** The share URL works
for anyone (by design, v0.5 note in README §collab). The editor shows
an honest view-only banner for other accounts’ designs — correct; just
worth documenting on the Share dialog for self-hosters.
+ **→ FIXED in v0.11.7** (the Share dialog now documents the enforced
+ model — link-editable ownerless designs, read-only owned designs, no
+ cloud gatekeeping — replacing a decorative access selector that
+ nothing enforced; `research/V0117-QA-FOLLOWUPS.md`).
## Enhancement candidates (beyond fixes)
diff --git a/research/V0117-QA-FOLLOWUPS.md b/research/V0117-QA-FOLLOWUPS.md
new file mode 100644
index 0000000..70acb03
--- /dev/null
+++ b/research/V0117-QA-FOLLOWUPS.md
@@ -0,0 +1,164 @@
+# v0.11.7 — QA follow-ups: F1 (deselect), F5 (render-phase writes), F6 (share docs)
+
+Closes out the three findings that stayed open after the v0.11.4–v0.11.6
+QA sweep (§5.2 of `research/V0114-QA-PASS.md`). All three were reproduced
+before fixing; the reproduction method is documented below because F5 in
+particular rewards it.
+
+## F1 — no deselect on empty-canvas click
+
+**Finding.** Clicking empty canvas kept the current selection; only
+Escape (and touch, via `handleStageTouchStart`) deselected. Canva
+deselects on empty click.
+
+**Mechanism.** A left click on empty canvas (`target === stage` or the
+`page-bg` rect) starts a marquee. On mouse-up, `selectInMarquee` treats a
+drag smaller than 4×4 page-pixels as "not a marquee" and early-returns —
+before ever reaching `clearSelection()`. A real drag that selects nothing
+*did* clear; only the bare click was left out.
+
+**Fix.** The zero-size branch now clears the selection — one honest line
+at the top of the branch (`CanvasStage.selectInMarquee`):
+
+```ts
+if (w < 4 && h < 4) {
+ clearSelection()
+ return
+}
+```
+
+Middle-mouse and space+drag panning already cleared (they still do), and
+viewing mode is untouched (the marquee never starts there).
+
+## F5 — "Cannot update a component (`X`) while rendering (`CanvasStage`)"
+
+**Finding.** The v0.11.4 QA console showed:
+
+```
+Cannot update a component (`MagicLayersDialog`) while rendering a
+different component (`CanvasStage`)
+```
+
+**Root cause — it was never about MagicLayers.** A Playwright
+reproduction with a patched `console.error` (capturing `new Error().stack`
+at log time — the warning fires synchronously inside the offending
+`setState`) pinned the real call chain:
+
+```
+Object.pushHistory (editor-store)
+Object.addElement (editor-store)
+CanvasStage.useEffect.commit ← window "mouseup" handler
+basicStateReducer ← the setDraft UPDATER running mid-render
+```
+
+Three gesture commits wrote the store from *inside* `setState` updaters:
+
+| gesture | updater | store write inside |
+| --- | --- | --- |
+| draw stroke commit | `setDraft((d) => …)` | `addElement(createStrokeElement(…))` |
+| marquee mouse-up | `setMarquee((m) => …)` | `setSelection` / `clearSelection` (via `selectInMarquee`) |
+| ruler guide drop | `setDraftGuide((d) => …)` | `addManualGuide(axis, position)` |
+
+React runs state updaters during the render of the component that owns
+the state — `CanvasStage`. The store write then synchronously notified
+subscribers (`forceStoreRerender` → `scheduleUpdateOnFiber`), i.e. it
+re-rendered *other* components while `CanvasStage` was mid-render. Which
+component the warning names depends on subscriber processing order — the
+QA session saw `MagicLayersDialog` (it is always mounted by `TopBar`),
+the reproduction saw `TopBar`. Same bug, different name; that
+nondeterminism is why the finding read like a MagicLayers bug.
+
+Notably, the full MagicLayers upload → analyze → review → create flow
+runs warning-free — verified directly against a mocked
+`/api/ai/magic-layers`.
+
+**Fix — commit at event time, never inside an updater.**
+
+- **Stroke**: the effect keeps a local `points` mirror, updated on every
+ mousemove; `commit()` reads it, calls `setDraft(null)` and — only
+ then — `addElement(...)`. The local mirror also removes a staleness
+ edge the functional updater used to handle (mouseup beating the
+ re-render after the last mousemove).
+- **Marquee**: a `marqueeShapeRef` mirror is seeded in
+ `handleStageMouseDown` and updated on every move; mouse-up reads the
+ ref, clears it, calls `setMarquee(null)` and then `selectInMarquee(m)`.
+- **Guide**: the axis is fixed for the whole drag, so the effect tracks
+ just `position` locally; mouse-up calls `setDraftGuide(null)` and then
+ `addManualGuide(axis, position)`.
+
+All three updaters that remain (`setDraft`, `setMarquee`, `setDraftGuide`
+during moves) are now pure.
+
+**A bonus interaction:** F1 had been *masking* the marquee variant of
+this warning — a bare click early-returned before any store write, so
+only drags and strokes could trigger it. Fixing F1 first would have made
+every empty-canvas click warn; the two fixes land together on purpose.
+
+## F6 — Share dialog documented the wrong access model
+
+**Finding.** The share URL works for anyone by design (v0.5; the v0.9
+README §accounts note). The editor shows an honest view-only banner for
+other accounts' designs. Worth documenting on the Share dialog for
+self-hosters.
+
+**What the dialog showed instead.** A decorative access selector —
+"Only me — Private to you", "Anyone with the link — Can view or edit",
+"Public — Listed in the community gallery" — persisted to
+`localStorage` and enforced by nothing (no code reads it; the community
+gallery does not exist). Documenting the real model next to it would
+have made the dialog contradict itself.
+
+**Fix.** The selector is replaced by a "Who can open this link" card
+stating the contract the server actually enforces
+(`src/lib/auth/design-guard.ts`):
+
+1. Anyone who can reach the instance can open the link — reachability
+ is decided by the deployment (LAN, VPN, reverse-proxy auth); Canvix
+ has no cloud gatekeeping.
+2. Ownerless designs (created while signed out) stay editable by
+ everyone with the link — the pre-accounts behaviour, kept on purpose.
+3. Designs owned by an account open read-only for everyone else:
+ view-only banner in the editor, 403 on every save.
+
+When the open design is read-only for you, the dialog says so (an amber
+note driven by the same `readOnly` flag the editor banner uses).
+
+## Two more finds while verifying (both pre-existing)
+
+**The ruler→guide initial position was computed from the wrong axis.**
+`rulers.tsx beginGuide()` fed `beginGuideFromRuler` an initial position
+from the *swapped* coordinate — mouse **X** for a horizontal guide
+(axis `y`), mouse **Y** for a vertical one (axis `x`). Harmless
+mid-drag (the first mousemove overwrote the value), but a bare click on
+a ruler committed a guide at a nonsense position, and the dashed draft
+flashed in the wrong place for one frame. Fixed to match the guide's
+axis (mouse Y from the TOP ruler, mouse X from the LEFT ruler).
+
+**`Konva.stages` order is a race — never address the editor by index.**
+The first E2E draft counted Konva nodes on `Konva.stages[0]`, which
+ intermittently failed: the **PageBar** mounts its page thumbnails
+(`design-preview.tsx` → `PreviewStage`) as their own mini Konva stages
+*inside the same `<main aria-label="Design canvas">`*, and their mount
+order races the editor canvas. (The stroke test passed by accident —
+strokes DO render in thumbnails; guides never do, because they are
+editor chrome, not document content.) The helper now picks the
+**largest** stage on the page, which is always the editor canvas,
+regardless of mount order.
+
+## Verification
+
+Reproduced all three before fixing (F5 via the stack-capture method
+above; F1 by hand; F6 by inspection of the dialog + guard code).
+
+Post-fix:
+
+- Playwright `tests/e2e/qa-followups.spec.ts` (5 tests, this PR): the F1
+ deselect click plus element re-select (no over-deselecting), marquee
+ re-select and empty-marquee clear, stroke draw and ruler-guide drop
+ each asserting **zero** "Cannot update a component" console errors,
+ and the F6 card contents (including the absence of the fake selector).
+- Full gates: `tsc --noEmit` clean, `eslint` clean, vitest 302/302,
+ Playwright 28/28 (23 + 5 new).
+- `research/V0114-QA-PASS.md` §5.2 annotated: F1/F5/F6 → FIXED in
+ v0.11.7. With this, all six findings of the v0.11.4 QA pass are
+ closed (F2/F3 in v0.11.6, F4 in v0.11.5).
diff --git a/src/components/editor/ShareDialog.tsx b/src/components/editor/ShareDialog.tsx
index dfaa3ab..f7c2c73 100644
--- a/src/components/editor/ShareDialog.tsx
+++ b/src/components/editor/ShareDialog.tsx
@@ -1,29 +1,26 @@
'use client'
-import { Link2, Check, Copy, Globe, Lock, QrCode } from 'lucide-react'
+import { Link2, Check, Copy, Eye, Info, QrCode } from 'lucide-react'
import { useState } from 'react'
import { useEditorStore } from '@/store/editor-store'
import { designShareUrl } from '@/lib/design-url'
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
-import { cn } from '@/lib/utils'
import { toast } from '@/hooks/use-toast'
-type Access = 'private' | 'link' | 'public'
+/**
+ * v0.11.7 (F6): the Share dialog documents the REAL access model instead of
+ * offering a decorative Only-me/Public selector that nothing enforced.
+ * The rules (src/lib/auth/design-guard.ts):
+ * • ownerless design (created signed-out) → anyone with the link can edit
+ * • design owned by an account → the owner edits; everyone else
+ * opens it read-only (honest
+ * view-only banner, 403 on saves)
+ * Canvix has no cloud access control — who can reach the link at all is
+ * decided by the deployment (LAN, VPN, reverse-proxy auth).
+ */
-const ACCESS_OPTS: { id: Access; label: string; desc: string; icon: typeof Lock }[] = [
- { id: 'private', label: 'Only me', desc: 'Private to you', icon: Lock },
- { id: 'link', label: 'Anyone with the link', desc: 'Can view or edit', icon: Link2 },
- { id: 'public', label: 'Public', desc: 'Listed in the community gallery', icon: Globe },
-]
-
-function readSavedAccess(designId: string | null): Access {
- if (typeof window === 'undefined' || !designId) return 'link'
- const saved = localStorage.getItem(`canvix:share:${designId}`)
- return saved === 'private' || saved === 'public' ? saved : 'link'
-}
-
-/** Canva-style Share dialog — copy link + access levels (local-first). */
+/** Canva-style Share dialog — copy link + the honest access model. */
export function ShareDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (v: boolean) => void }) {
const designId = useEditorStore((s) => s.designId)
const designName = useEditorStore((s) => s.designName)
@@ -46,25 +43,21 @@ export function ShareDialog({ open, onOpenChange }: { open: boolean; onOpenChang
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="rounded-[28px] bg-[#16181D] border-white/10 text-white sm:max-w-md">
- {open && <ShareBody designId={designId} designName={designName} link={link} copied={copied} onCopy={() => void copy()} />}
+ <ShareBody designName={designName} link={link} copied={copied} onCopy={() => void copy()} />
</DialogContent>
</Dialog>
)
}
-function ShareBody({ designId, designName, link, copied, onCopy }: {
- designId: string | null
+function ShareBody({ designName, link, copied, onCopy }: {
designName: string
link: string
copied: boolean
onCopy: () => void
}) {
- const [access, setAccess] = useState<Access>(() => readSavedAccess(designId))
-
- const setAccessAndPersist = (a: Access) => {
- setAccess(a)
- if (designId) localStorage.setItem(`canvix:share:${designId}`, a)
- }
+ // v0.9: the editor already knows when the open design belongs to another
+ // account — surface it here so the access card describes THIS design
+ const readOnly = useEditorStore((s) => s.readOnly)
return (
<>
@@ -93,25 +86,44 @@ function ShareBody({ designId, designName, link, copied, onCopy }: {
</Button>
</div>
- <div className="rounded-xl border border-white/10 overflow-hidden divide-y divide-white/10">
- {ACCESS_OPTS.map((o) => (
- <button
- key={o.id}
- onClick={() => setAccessAndPersist(o.id)}
- className={cn(
- 'w-full flex items-center gap-3 px-3 py-3 text-left transition-colors',
- access === o.id ? 'bg-[#7630D7]/25' : 'hover:bg-white/5'
- )}
- aria-pressed={access === o.id}
- >
- <o.icon size={17} className={access === o.id ? 'text-[#a78bfa]' : 'text-white/60'} />
- <span className="flex-1 min-w-0">
- <span className="block text-[13px] font-semibold">{o.label}</span>
- <span className="block text-[11px] text-white/50">{o.desc}</span>
+ {/* F6 (v0.11.7): the honest access model, documented where the link
+ is handed out — this is the contract the server actually enforces */}
+ <div className="rounded-xl border border-white/10 bg-white/[0.03] p-3.5 space-y-2">
+ <div className="text-xs font-semibold text-white/75 flex items-center gap-1.5">
+ <Info size={13} className="text-[#02C0CC] shrink-0" /> Who can open this link
+ </div>
+ <ul className="text-[11px] leading-relaxed text-white/55 space-y-1.5 list-none">
+ <li className="flex gap-2">
+ <span aria-hidden className="text-white/35">•</span>
+ <span>
+ Anyone who can reach this Canvix instance. There is no cloud gatekeeping — reachability is decided by
+ your deployment (LAN, VPN or reverse-proxy auth).
+ </span>
+ </li>
+ <li className="flex gap-2">
+ <span aria-hidden className="text-white/35">•</span>
+ <span>
+ <strong className="text-white/75">Ownerless designs</strong> (created while signed out) stay editable by
+ everyone with the link — the pre-accounts behaviour, kept on purpose so existing shares never break.
+ </span>
+ </li>
+ <li className="flex gap-2">
+ <span aria-hidden className="text-white/35">•</span>
+ <span>
+ <strong className="text-white/75">Owned designs</strong> open read-only for everyone except the owner:
+ an honest view-only banner in the editor, and every save answers 403.
+ </span>
+ </li>
+ </ul>
+ {readOnly && (
+ <div className="flex items-start gap-2 rounded-lg border border-amber-400/30 bg-amber-400/10 p-2.5 text-[11px] text-amber-200/90">
+ <Eye size={13} className="shrink-0 mt-0.5" />
+ <span>
+ You are viewing this design read-only — it belongs to another account. The link still opens it for
+ anyone who has it.
</span>
- {access === o.id && <Check size={15} className="text-[#a78bfa] shrink-0" />}
- </button>
- ))}
+ </div>
+ )}
</div>
<p className="text-[11px] text-white/40 flex items-center gap-1.5">
diff --git a/src/components/editor/canvas/CanvasStage.tsx b/src/components/editor/canvas/CanvasStage.tsx
index 4daa348..612d174 100644
--- a/src/components/editor/canvas/CanvasStage.tsx
+++ b/src/components/editor/canvas/CanvasStage.tsx
@@ -77,6 +77,11 @@ export default function CanvasStage() {
const [draftGuide, setDraftGuide] = useState<{ axis: 'x' | 'y'; position: number } | null>(null)
const drawingRef = useRef(false)
const marqueeRef = useRef(false)
+ /** v0.11.7 (F5): latest marquee rect for the window-level gesture
+ * listeners — lets mouseup select OUTSIDE any setState updater.
+ * (Store writes inside updaters run during render and trigger React's
+ * "Cannot update a component while rendering a different component".) */
+ const marqueeShapeRef = useRef<{ x0: number; y0: number; x1: number; y1: number } | null>(null)
const spaceRef = useRef(false)
const interactive = editingMode === 'editing' && tool === 'select' && !commentsOpen
@@ -370,7 +375,12 @@ export default function CanvasStage() {
const selectInMarquee = (a: { x0: number; y0: number; x1: number; y1: number }) => {
const x = Math.min(a.x0, a.x1), y = Math.min(a.y0, a.y1)
const w = Math.abs(a.x1 - a.x0), h = Math.abs(a.y1 - a.y0)
- if (w < 4 && h < 4) return
+ if (w < 4 && h < 4) {
+ // v0.11.7 (F1): a bare click on empty canvas deselects — Canva parity.
+ // (Touches already did this in handleStageTouchStart; Escape always could.)
+ clearSelection()
+ return
+ }
const hits = page.elements
.filter((e) => e.visible && !e.locked)
.filter((e) => e.x < x + w && e.x + e.width > x && e.y < y + h && e.y + e.height > y)
@@ -383,19 +393,21 @@ export default function CanvasStage() {
const guideDragging = draftGuide !== null
useEffect(() => {
if (!guideDragging) return
+ // v0.11.7 (F5): the guide's axis is fixed for the whole drag; the
+ // position is tracked locally so mouseup can commit the guide at EVENT
+ // time — outside any setState updater (updaters run during render).
+ const axis = draftGuide?.axis ?? 'x'
+ let position = draftGuide?.position ?? 0
const onMove = (e: MouseEvent) => {
const pt = pagePoint(e.clientX, e.clientY)
if (!pt) return
- setDraftGuide((d) => (d ? { ...d, position: d.axis === 'x' ? pt.x : pt.y } : d))
+ position = axis === 'x' ? pt.x : pt.y
+ setDraftGuide((d) => (d ? { ...d, position } : d))
}
const onUp = () => {
- setDraftGuide((d) => {
- if (d) {
- const limit = d.axis === 'x' ? width : height
- if (d.position > -30 && d.position < limit + 30) addManualGuide(d.axis, d.position)
- }
- return null
- })
+ setDraftGuide(null)
+ const limit = axis === 'x' ? width : height
+ if (position > -30 && position < limit + 30) addManualGuide(axis, position)
}
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') setDraftGuide(null)
@@ -476,7 +488,9 @@ export default function CanvasStage() {
const pt = pagePoint(e.evt.clientX, e.evt.clientY)
if (!pt) return
marqueeRef.current = true
- setMarquee({ x0: pt.x, y0: pt.y, x1: pt.x, y1: pt.y })
+ const m = { x0: pt.x, y0: pt.y, x1: pt.x, y1: pt.y }
+ marqueeShapeRef.current = m
+ setMarquee(m)
}
}
@@ -507,7 +521,14 @@ export default function CanvasStage() {
const onMove = (e: MouseEvent) => {
if (marqueeRef.current) {
const pt = pagePoint(e.clientX, e.clientY)
- if (pt) setMarquee((m) => (m ? { ...m, x1: pt.x, y1: pt.y } : m))
+ if (pt) {
+ const prev = marqueeShapeRef.current
+ if (prev) {
+ const next = { ...prev, x1: pt.x, y1: pt.y }
+ marqueeShapeRef.current = next
+ setMarquee(next)
+ }
+ }
return
}
movePan(e.clientX, e.clientY)
@@ -515,10 +536,13 @@ export default function CanvasStage() {
const onUp = () => {
if (marqueeRef.current) {
marqueeRef.current = false
- setMarquee((m) => {
- if (m) selectInMarquee(m)
- return null
- })
+ // v0.11.7 (F5): select at event time, NOT inside the setMarquee
+ // updater — updaters run during render, and the store write would
+ // re-render other components mid-render (the F5 warning)
+ const m = marqueeShapeRef.current
+ marqueeShapeRef.current = null
+ setMarquee(null)
+ if (m) selectInMarquee(m)
return
}
endPan()
@@ -608,6 +632,11 @@ export default function CanvasStage() {
// ── freehand drawing (window-level so strokes continue off-element) ────
useEffect(() => {
if (!drawingRef.current && draft === null) return
+ // v0.11.7 (F5): local mirror of the stroke-so-far — mouseup commits the
+ // element from it at event time, OUTSIDE the setDraft updater (updaters
+ // run during render; the store write re-rendered other components
+ // mid-render → "Cannot update a component while rendering …").
+ let points = draft
const onMove = (e: MouseEvent) => {
if (!drawingRef.current) return
const stage = stageRef.current
@@ -615,28 +644,28 @@ export default function CanvasStage() {
if (!stage || !container) return
const px = (e.clientX - container.left - pan.x) / zoom
const py = (e.clientY - container.top - pan.y) / zoom
- setDraft((d) => (d ? [...d, px, py] : [px, py, px, py]))
+ points = points ? [...points, px, py] : [px, py, px, py]
+ setDraft(points)
}
const commit = () => {
if (!drawingRef.current) return
drawingRef.current = false
- setDraft((d) => {
- if (d && d.length >= 6) {
- const minX = Math.min(...d.filter((_, i) => i % 2 === 0))
- const minY = Math.min(...d.filter((_, i) => i % 2 === 1))
- const rel = d.map((v, i) => (i % 2 === 0 ? v - minX : v - minY))
- useEditorStore.getState().addElement(
- createStrokeElement({
- x: Math.round(minX),
- y: Math.round(minY),
- points: rel.map((v) => Math.round(v)),
- stroke: drawColor,
- strokeWidth: drawSize,
- })
- )
- }
- return null
- })
+ const d = points
+ setDraft(null)
+ if (d && d.length >= 6) {
+ const minX = Math.min(...d.filter((_, i) => i % 2 === 0))
+ const minY = Math.min(...d.filter((_, i) => i % 2 === 1))
+ const rel = d.map((v, i) => (i % 2 === 0 ? v - minX : v - minY))
+ useEditorStore.getState().addElement(
+ createStrokeElement({
+ x: Math.round(minX),
+ y: Math.round(minY),
+ points: rel.map((v) => Math.round(v)),
+ stroke: drawColor,
+ strokeWidth: drawSize,
+ })
+ )
+ }
}
window.addEventListener('mousemove', onMove)
window.addEventListener('mouseup', commit)
diff --git a/src/components/editor/canvas/rulers.tsx b/src/components/editor/canvas/rulers.tsx
index 558153c..6ec079a 100644
--- a/src/components/editor/canvas/rulers.tsx
+++ b/src/components/editor/canvas/rulers.tsx
@@ -188,10 +188,15 @@ export function Rulers({ width, height, zoom, pan, containerW, containerH, onGui
const beginGuide = (axis: 'x' | 'y', e: React.MouseEvent<HTMLCanvasElement>) => {
const container = (e.currentTarget.parentElement as HTMLElement)?.getBoundingClientRect()
if (!container) return
+ // v0.11.7: position must match the guide's axis — mouse Y for a horizontal
+ // guide from the TOP ruler, mouse X for a vertical guide from the LEFT
+ // ruler. (These were swapped: harmless mid-drag — the first mousemove
+ // overwrote the value — but a bare ruler click committed a guide at a
+ // nonsense position, and the dashed draft flashed in the wrong place.)
const pagePos =
axis === 'y'
- ? (e.clientX - container.left - pan.x) / zoom // horizontal guide from the TOP ruler
- : (e.clientY - container.top - pan.y) / zoom // vertical guide from the LEFT ruler
+ ? (e.clientY - container.top - pan.y) / zoom // horizontal guide from the TOP ruler
+ : (e.clientX - container.left - pan.x) / zoom // vertical guide from the LEFT ruler
onGuideStart(axis, pagePos)
}
diff --git a/tests/e2e/qa-followups.spec.ts b/tests/e2e/qa-followups.spec.ts
new file mode 100644
index 0000000..29dd4f0
--- /dev/null
+++ b/tests/e2e/qa-followups.spec.ts
@@ -0,0 +1,202 @@
+import { test, expect, type Page } from '@playwright/test'
+
+/**
+ * v0.11.7 — QA follow-ups (research/V0114-QA-PASS.md §5.2, the three
+ * findings that stayed open after v0.11.6):
+ *
+ * F1: clicking empty canvas kept the current selection — only Escape (and
+ * touch) deselected. Fix: a bare click is a zero-size marquee, and
+ * selectInMarquee now clears the selection for it (Canva parity).
+ * F5: "Cannot update a component (`X`) while rendering a different
+ * component (`CanvasStage`)" — three store writes lived INSIDE setState
+ * updaters (draw-stroke commit, marquee select, ruler-guide drop).
+ * Updaters run during render, so each write re-rendered other
+ * components mid-render. Fix: all three now commit at event time.
+ * F6: the Share dialog offered a decorative Only-me/Public access
+ * selector that nothing enforced; it now documents the real model
+ * (ownerless = link-editable, owned = read-only for others, no cloud
+ * gatekeeping) — see src/lib/auth/design-guard.ts.
+ *
+ * Needs a database (design creation) — see playwright.config.ts.
+ */
+test.setTimeout(120_000)
+
+async function openBlankEditor(page: Page) {
+ await page.goto('/')
+ // Next.js dev tools indicator overlays the first rail button in dev mode
+ await page.addStyleTag({ content: 'nextjs-portal { display: none !important; }' })
+ await page.getByRole('button', { name: /start designing/i }).first().click()
+ await page
+ .locator('section:has(h2:text("Start a new design")) [aria-label^="Create "]')
+ .first()
+ .click()
+ await expect(page.getByLabel('Design canvas')).toBeVisible({ timeout: 30_000 })
+}
+
+/** collect React's render-phase update warnings ("Cannot update a component…") */
+function watchRenderPhaseWarnings(page: Page): () => string[] {
+ const bad: string[] = []
+ page.on('console', (m) => {
+ if (m.type() === 'error' && m.text().includes('Cannot update a component')) bad.push(m.text())
+ })
+ return () => bad
+}
+
+/** count Konva nodes of a type on the MAIN editor stage.
+ * NB: never trust `Konva.stages` order or "inside the design canvas <main>"
+ * alone — the PageBar mounts its DesignPreview thumbnails (also Konva
+ * stages) INSIDE that <main>, and their mount order races the canvas. The
+ * editor canvas is by far the largest stage on the page, so pick largest. */
+function konvaCount(page: Page, selector: string): Promise<number> {
+ return page.evaluate(
+ (sel) => {
+ const Konva = (window as unknown as {
+ Konva?: { stages: Array<{ width: () => number; height: () => number; find: (s: string) => unknown[] }> }
+ }).Konva
+ const stages = Konva?.stages ?? []
+ const stage = stages.reduce<
+ { width: () => number; height: () => number; find: (s: string) => unknown[] } | null
+ >((best, s) => (!best || s.width() * s.height() > best.width() * best.height() ? s : best), null)
+ return stage ? stage.find(sel).length : -1
+ },
+ selector
+ )
+}
+
+// ── F1 ─────────────────────────────────────────────────────────
+
+test('F1: clicking empty canvas deselects the current selection', async ({ page }) => {
+ const warnings = watchRenderPhaseWarnings(page)
+ await openBlankEditor(page)
+
+ // add a heading — addElement auto-selects it, so the top bar swaps its
+ // left section for the context toolbar (the File menu disappears)
+ await page.getByRole('button', { name: 'Text', exact: true }).click()
+ await page.getByLabel('Add a heading').click()
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeHidden()
+
+ // THE BUG (F1): a bare click on empty canvas used to keep the selection
+ const box = (await page.getByLabel('Design canvas').boundingBox())!
+ await page.mouse.click(box.x + box.width * 0.22, box.y + box.height * 0.25)
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeVisible()
+
+ // clicking the heading still selects it (no regression from the fix)
+ await page.mouse.click(box.x + box.width * 0.5, box.y + box.height * 0.475)
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeHidden()
+
+ expect(warnings(), 'F5: no render-phase update warnings').toEqual([])
+})
+
+test('F1/F5: a marquee drag still selects — and commits cleanly at event time', async ({ page }) => {
+ const warnings = watchRenderPhaseWarnings(page)
+ await openBlankEditor(page)
+
+ await page.getByRole('button', { name: 'Text', exact: true }).click()
+ await page.getByLabel('Add a heading').click()
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeHidden()
+
+ // deselect via the F1 click, then re-select by dragging a marquee across
+ // the centered heading
+ const box = (await page.getByLabel('Design canvas').boundingBox())!
+ await page.mouse.click(box.x + box.width * 0.22, box.y + box.height * 0.25)
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeVisible()
+
+ await page.mouse.move(box.x + box.width * 0.18, box.y + box.height * 0.2)
+ await page.mouse.down()
+ await page.mouse.move(box.x + box.width * 0.8, box.y + box.height * 0.8, { steps: 6 })
+ await page.mouse.up()
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeHidden()
+
+ // a drag that selects nothing clears instead of sticking
+ await page.mouse.move(box.x + box.width * 0.18, box.y + box.height * 0.15)
+ await page.mouse.down()
+ await page.mouse.move(box.x + box.width * 0.35, box.y + box.height * 0.3, { steps: 4 })
+ await page.mouse.up()
+ await expect(page.getByRole('button', { name: 'File menu' })).toBeVisible()
+
+ expect(warnings(), 'F5: no render-phase update warnings').toEqual([])
+})
+
+// ── F5 ─────────────────────────────────────────────────────────
+
+test('F5: drawing a stroke commits without render-phase update warnings', async ({ page }) => {
+ const warnings = watchRenderPhaseWarnings(page)
+ await openBlankEditor(page)
+
+ // activate Draw from the top-bar mode menu (the v0.11.6 path)
+ await page.getByRole('button', { name: 'Editing mode' }).click()
+ await page.getByRole('menuitem', { name: /Draw — freehand brush/ }).click()
+
+ const box = (await page.getByLabel('Design canvas').boundingBox())!
+ await page.mouse.move(box.x + box.width * 0.3, box.y + box.height * 0.6)
+ await page.mouse.down()
+ for (let i = 1; i <= 6; i++) {
+ await page.mouse.move(box.x + box.width * (0.3 + i * 0.05), box.y + box.height * 0.6 + (i % 2 ? 8 : -8))
+ }
+ await page.mouse.up()
+
+ // the stroke landed as a real Konva Line node (poll: the commit renders async)
+ await expect
+ .poll(() => konvaCount(page, 'Line'), { timeout: 10_000 })
+ .toBeGreaterThanOrEqual(1)
+ expect(warnings(), 'F5: the draw commit must not write the store inside a setState updater').toEqual([])
+})
+
+test('F5: dropping a ruler guide commits without render-phase update warnings', async ({ page }) => {
+ const warnings = watchRenderPhaseWarnings(page)
+ await openBlankEditor(page)
+
+ await page.getByRole('button', { name: 'File menu' }).click()
+ await page.getByRole('menuitem', { name: /Show rulers/ }).click()
+ const ruler = page.getByLabel('Horizontal ruler — drag to create a guide')
+ await expect(ruler).toBeVisible()
+
+ const canvas = page.getByLabel('Design canvas')
+ const box = (await canvas.boundingBox())!
+ const before = await konvaCount(page, 'Line')
+
+ // drag slowly: mousedown → let the guide effect attach its window
+ // listeners → several moves → release. A single-shot dispatch can race
+ // the effect registration in headless runs.
+ await ruler.hover() // actionability-checked position on the ruler strip
+ await page.mouse.down()
+ await page.waitForTimeout(120)
+ const tx = box.x + box.width * 0.5
+ const ty = box.y + box.height * 0.45
+ for (let i = 1; i <= 6; i++) {
+ await page.mouse.move(tx, box.y + 11 + (ty - (box.y + 11)) * (i / 6))
+ await page.waitForTimeout(40)
+ }
+ await page.waitForTimeout(80)
+ await page.mouse.up()
+
+ // the guide lands as a draggable Konva Line (poll: the commit renders async)
+ await expect
+ .poll(() => konvaCount(page, 'Line'), { timeout: 10_000 })
+ .toBe(before + 1)
+ expect(warnings(), 'F5: the guide commit must not write the store inside a setState updater').toEqual([])
+})
+
+// ── F6 ─────────────────────────────────────────────────────────
+
+test('F6: the Share dialog documents the real link-access model', async ({ page }) => {
+ await openBlankEditor(page)
+ await page.getByRole('button', { name: 'Share' }).click()
+ const dlg = page.getByRole('dialog')
+
+ // the canonical link is still the centerpiece
+ await expect(dlg.getByLabel('Share link')).toHaveValue(/\/design\//)
+
+ // the honest access card (F6): the rules the server actually enforces
+ await expect(dlg.getByText('Who can open this link')).toBeVisible()
+ await expect(dlg.getByText(/Anyone who can reach this Canvix instance/)).toBeVisible()
+ await expect(dlg.getByText(/Ownerless designs/)).toBeVisible()
+ await expect(dlg.getByText(/read-only for everyone except the owner/)).toBeVisible()
+
+ // the decorative, unenforced access selector is gone
+ await expect(dlg.getByRole('button', { name: /Only me/ })).toHaveCount(0)
+ await expect(dlg.getByText(/community gallery/)).toHaveCount(0)
+
+ // this design is ownerless (created signed-out) — no read-only note
+ await expect(dlg.getByText(/viewing this design read-only/)).toHaveCount(0)
+})