From 730ea7641365625517bb518bcf468a7a41c54733 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:54:39 -0500 Subject: [PATCH 01/36] M1: Frame selection makes a frame without a fill Alt+Cmd/Ctrl+G wrapped the selection in a new frame with the white fill a drawn frame gets, which covered the page behind the framed layers. The frame made around a selection now has no fill; a frame drawn with the Frame tool keeps its white fill. Test: frames_behaviour_tests (frame selection). --- crates/engine/src/cmd/structure.rs | 1 + crates/engine/src/frames_behaviour_tests.rs | 1 + docs/ui-parity.md | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/structure.rs b/crates/engine/src/cmd/structure.rs index bf1c92d2f..aa4b9464f 100644 --- a/crates/engine/src/cmd/structure.rs +++ b/crates/engine/src/cmd/structure.rs @@ -238,6 +238,7 @@ fn wrap(s: &mut Session, p: &Value, cmd: &str, w: Wrap) -> Result { } if let Wrap::Frame = w { g.clip = true; + g.fills.clear(); } // Insert the container where the topmost layer is. doc.insert(g, parent, index)?; diff --git a/crates/engine/src/frames_behaviour_tests.rs b/crates/engine/src/frames_behaviour_tests.rs index 683c6383d..85a26fc6c 100644 --- a/crates/engine/src/frames_behaviour_tests.rs +++ b/crates/engine/src/frames_behaviour_tests.rs @@ -188,6 +188,7 @@ fn frame_selection_wraps_the_layers_where_the_topmost_was() { assert_eq!(doc.node(page).unwrap().children, vec![other, f, top], "where b (the topmost selected) was"); assert_eq!((wb(&s, a), wb(&s, b)), ((10.0, 10.0, 20.0, 20.0), (50.0, 40.0, 30.0, 30.0))); assert_eq!(s.selection(), vec![f]); + assert!(doc.node(f).unwrap().fills.is_empty(), "no fill over what it frames: {:?}", doc.node(f).unwrap().fills); // Inside a frame, the new frame nests there. let outer = frame(&mut s, 500.0, 0.0, 200.0, 200.0, None); let c = rect(&mut s, 20.0, 20.0, 10.0, 10.0, Some(outer)); diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..131cc9cdf 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (M1: Frame selection makes a frame without a fill; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-15 | patch | M1: Frame selection (Alt+Cmd/Ctrl+G) gave the new frame the white fill a drawn frame gets, which covered the page behind the framed layers. It now has no fill; a frame drawn with the Frame tool keeps its white fill. Test: `frames_behaviour_tests` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From b1692e44b7fab8932fc36160211a8a8137fdb748 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:58:27 -0500 Subject: [PATCH 02/36] M1: Centred auto-width text grows and shrinks about its middle Typing in a centre-aligned auto-width text kept its left edge, so the text crept to the right as it was edited instead of staying centred. Right-aligned auto-width text already kept its right edge (#1477); the same rule now keeps the middle of centred text in place, half of the width change going to each side, also when the text is rotated. It applies as #1477's does: only when the text was centred auto-width text before the edit, and not where an auto layout flow places it. Tests: text_behaviour_tests (centred and left-aligned auto-width text). --- crates/engine/src/derived.rs | 28 +++++++++++----- crates/engine/src/text_behaviour_tests.rs | 39 +++++++++++++++++++++++ docs/ui-parity.md | 3 +- 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/derived.rs b/crates/engine/src/derived.rs index 54356e2c9..05226d143 100644 --- a/crates/engine/src/derived.rs +++ b/crates/engine/src/derived.rs @@ -83,10 +83,12 @@ pub fn normalize(doc: &mut Document, before: &Document) { && ((w - n.width).abs() > 1e-6 || (h - n.height).abs() > 1e-6) { let dw = w - n.width; - let anchor_right = keeps_right_edge(doc, before, n); + let left_share = share_of_growth_to_the_left(doc, before, n); figcraft_layout::set_size(doc, id, w, h); - if anchor_right && let Some(n) = doc.node_mut(id) { - n.transform *= figcraft_geom::kurbo::Affine::translate((-dw, 0.0)); + if left_share > 0.0 + && let Some(n) = doc.node_mut(id) + { + n.transform *= figcraft_geom::kurbo::Affine::translate((-dw * left_share, 0.0)); } } } @@ -218,13 +220,23 @@ pub(crate) fn only_moved_layers(doc: &mut Document, before: &Document, touched: out } -/// Whether auto-width text `n` keeps its right edge when its width changes: it was already -/// right-aligned auto-width text before the edit and no auto layout flow places it. -fn keeps_right_edge(doc: &Document, before: &Document, n: &Node) -> bool { +/// How much of a width change auto-width text `n` takes on its left: all of it when right +/// aligned (it keeps its right edge), half when centred (it keeps its middle), none otherwise. +/// Only when it had the same alignment as auto-width text before the edit and no auto layout +/// flow places it. +fn share_of_growth_to_the_left(doc: &Document, before: &Document, n: &Node) -> f64 { use figcraft_doc::{TextAlignH, TextAutoResize}; - let right_auto = |n: &Node| n.kind.text().is_some_and(|t| t.align_h == TextAlignH::Right && t.auto_resize == TextAutoResize::WidthAndHeight); + let auto_width_align = |n: &Node| n.kind.text().filter(|t| t.auto_resize == TextAutoResize::WidthAndHeight).map(|t| t.align_h); let in_flow = !n.child_layout.absolute && n.parent.and_then(|p| doc.node(p)).is_some_and(|p| p.layout.is_some() && p.kind.is_frame_like()); - right_auto(n) && before.node(n.id).is_some_and(right_auto) && !in_flow + let align = auto_width_align(n); + if in_flow || align != before.node(n.id).and_then(auto_width_align) { + return 0.0; + } + match align { + Some(TextAlignH::Right) => 1.0, + Some(TextAlignH::Center) => 0.5, + _ => 0.0, + } } /// Whether layer `id` changed (since `before`) in a way that can move or resize layers in an auto diff --git a/crates/engine/src/text_behaviour_tests.rs b/crates/engine/src/text_behaviour_tests.rs index 74a013e90..40575275d 100644 --- a/crates/engine/src/text_behaviour_tests.rs +++ b/crates/engine/src/text_behaviour_tests.rs @@ -960,3 +960,42 @@ fn setting_characters_as_a_command_never_renames_the_layer() { s.execute("node.set", &json!({"id": t, "props": {"characters": "Site em 7 dias"}})).unwrap(); assert_eq!((chars(&s, t).as_str(), layer_name(&s, t).as_str()), ("Site em 7 dias", "Title"), "the field keeps its name"); } + +fn top_middle(s: &Session, t: NodeId) -> (f64, f64) { + let doc = s.doc().unwrap(); + let p = doc.world_transform(t) * figcraft_geom::kurbo::Point::new(doc.node(t).unwrap().width / 2.0, 0.0); + (p.x, p.y) +} + +#[test] +fn centred_auto_width_text_grows_and_shrinks_both_ways() { + let font = test_mono_font(); + for (src, rotation) in [("ANCHOR TEST\nabc", 0.0), ("abc", 0.0), ("abc", 90.0)] { + let mut s = Session::new(); + let t = text(&mut s, src, json!({"fontSize": 40, "fontFamily": font, "textAlign": "center", "textAutoResize": "widthAndHeight"})); + s.execute("node.set", &json!({"id": t, "props": {"x": 200, "y": 50, "rotation": rotation}})).unwrap(); + let anchor = top_middle(&s, t); + let w0 = size(&s, t).0; + begin(&mut s, t, Some(src.chars().count()), false).unwrap(); + for c in "defghijklmnopqrstuvwxyz".chars() { + crate::textedit::insert(&mut s, &c.to_string()).unwrap(); + assert_near(top_middle(&s, t), anchor, &format!("{src:?} at {rotation}°: typing {c}")); + } + assert!(size(&s, t).0 > w0 + 1e-6, "{src:?} at {rotation}°: typing grows the text"); + for _ in 0..23 { + key(&mut s, "Backspace", false, false, false).unwrap(); + assert_near(top_middle(&s, t), anchor, &format!("{src:?} at {rotation}°: deleting")); + } + assert!((size(&s, t).0 - w0).abs() < 1e-6, "back to the starting width"); + } +} + +#[test] +fn left_aligned_auto_width_text_still_grows_to_the_right() { + let font = test_mono_font(); + let mut s = Session::new(); + let t = text(&mut s, "abc", json!({"fontSize": 40, "fontFamily": font, "textAutoResize": "widthAndHeight"})); + let left = s.doc().unwrap().world_transform(t); + s.execute("node.set", &json!({"id": t, "props": {"characters": "abcdefghijklmnop"}})).unwrap(); + assert_eq!(s.doc().unwrap().world_transform(t), left); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..36d7d785f 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (M1: centred auto-width text keeps its middle as it grows and shrinks; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-15 | patch | M1: typing in centred auto-width text kept its left edge, so the text crept to the right. It now keeps its middle, half of each width change going to each side, also when rotated, under the same conditions as right-aligned text keeps its right edge (#1477). Tests: `text_behaviour_tests` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 20a49eb5868c43fc494e3696d507f3a02a30385a Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:29:35 -0500 Subject: [PATCH 03/36] M8: in vector edit mode, deleting a point selects the next one on its path Deleting a selected point (Delete or Backspace, or Shift+Delete to heal) cleared the selection, so removing several points along a path meant clicking each one before every Delete. Before the points go, each one's follower is found by walking its path forward (segment a to b) past the points being deleted, or backward when the path ends there. After the deletion those followers are found again by position, as the deleted points already were, and become the selection of their layer, so Delete pressed again goes on along the path. A cut (vector_clipboard) still leaves nothing selected. --- crates/engine/src/canvas/vectoredit.rs | 47 +++++++++++++++++-- .../engine/src/cmd/edit/vector_clipboard.rs | 2 +- crates/engine/src/vector_behaviour_tests.rs | 25 ++++++++++ docs/ui-parity.md | 3 +- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/canvas/vectoredit.rs b/crates/engine/src/canvas/vectoredit.rs index ff8af30a4..cf00a06de 100644 --- a/crates/engine/src/canvas/vectoredit.rs +++ b/crates/engine/src/canvas/vectoredit.rs @@ -642,10 +642,12 @@ fn index(cmd: &str, p: &Value, key: &str) -> Result { } /// Delete the points and segments of `parts` (`heal` keeps paths through deleted points closed). -pub(crate) fn delete_selection(s: &mut Session, parts: Vec, heal: bool) -> Result<()> { +pub(crate) fn delete_selection(s: &mut Session, parts: Vec, heal: bool, then_select_next: bool) -> Result<()> { let doc = s.doc_mut()?; + let mut next = Vec::new(); for EditPart { id, vertices: verts, segments: segs } in parts { - edit(doc, id, |net| { + let following = edit(doc, id, |net| { + let following = if then_select_next { points_following(net, &verts) } else { Vec::new() }; // Segments first (their indices refer to the network before points go). let segs: Vec = segs.into_iter().filter(|si| net.segments.get(*si).is_some_and(|x| !verts.contains(&x.a) && !verts.contains(&x.b))).collect(); @@ -654,15 +656,52 @@ pub(crate) fn delete_selection(s: &mut Session, parts: Vec, heal: bool // Point indices may have shifted: find them again by position. let now: Vec = pts.iter().filter_map(|p| net.vertices.iter().position(|v| v.point() == *p)).collect(); ops::delete_vertices(net, &now, heal); + following.iter().filter_map(|p| net.vertices.iter().position(|v| v.point() == *p)).collect::>() })?; + next.push((id, following)); } set_state(s, |ve| { ve.clear_selection(); ve.anchor = None; ve.pen_out = None; + for (id, following) in next { + if id == ve.id { + ve.vertices = following; + } else if let Some(o) = ve.others.iter_mut().find(|o| o.id == id) { + o.vertices = following; + } + } }) } +fn points_following(net: &VectorNetwork, deleted: &[usize]) -> Vec { + let step = |from: usize, forward: bool| { + net.segments.iter().find_map(|sg| match forward { + true => (sg.a == from).then_some(sg.b), + false => (sg.b == from).then_some(sg.a), + }) + }; + let mut out: Vec = Vec::new(); + for &v in deleted { + let found = [true, false].into_iter().find_map(|forward| { + let mut at = v; + for _ in 0..net.vertices.len() { + at = step(at, forward)?; + if !deleted.contains(&at) { + return Some(at); + } + } + None + }); + if let Some(p) = found.and_then(|i| net.vertices.get(i)).map(|x| x.point()) + && !out.contains(&p) + { + out.push(p); + } + } + out +} + /// The points a command acts on, per layer: `vertices` names points of the active layer; without /// it, every edited layer's selected points (with `ends`, the ends of selected segments too). fn point_sets(s: &Session, p: &Value, ends: bool) -> Result)>> { @@ -1112,7 +1151,7 @@ pub fn specs() -> Vec { }), spec!("vector.deleteHeal", "Delete and heal selection", "{vertices?} (default the selected points of every edited layer)", true, |s, p| { let parts = point_sets(s, p, false)?.into_iter().map(|(id, vertices)| EditPart { id, vertices, segments: vec![] }).collect(); - delete_selection(s, parts, true)?; + delete_selection(s, parts, true, true)?; Ok(json!({"ok": true})) }), spec!("vector.edit.delete", "Delete points", "{vertices?, segments?} (default the selection in every edited layer)", true, |s, p| { @@ -1121,7 +1160,7 @@ pub fn specs() -> Vec { (None, None) => ve.parts(), (v, sg) => vec![EditPart { id: ve.id, vertices: v.unwrap_or_default(), segments: sg.unwrap_or_default() }], }; - delete_selection(s, parts, false)?; + delete_selection(s, parts, false, true)?; Ok(json!({"ok": true})) }), spec!("vector.edit.cornerRadius", "Point corner radius", "{radius, vertices?}", true, |s, p| { diff --git a/crates/engine/src/cmd/edit/vector_clipboard.rs b/crates/engine/src/cmd/edit/vector_clipboard.rs index 72c60bf02..f52916ee8 100644 --- a/crates/engine/src/cmd/edit/vector_clipboard.rs +++ b/crates/engine/src/cmd/edit/vector_clipboard.rs @@ -154,7 +154,7 @@ pub(super) fn cut_selection(s: &mut Session, sel: EditSelection) -> Result>(); + let second = point_at(&s, id, (100.0, 0.0)); + ex(&mut s, "vector.edit.select", json!({"vertices": [second]})); + key(&mut s, "Delete", true); + assert_eq!(selected(&s), [Point::new(200.0, 0.0)], "the point after the deleted one"); + key(&mut s, "Delete", true); + assert_eq!(selected(&s), [Point::new(300.0, 0.0)], "so Delete again walks along the path"); + key(&mut s, "Delete", true); + assert_eq!(selected(&s), [Point::new(0.0, 0.0)], "past the path's end, the point before it"); + + let mut s = Session::new(); + let id = square(&mut s, true); + let tr = point_at(&s, id, (100.0, 0.0)); + ex(&mut s, "vector.edit.select", json!({"vertices": [tr]})); + key(&mut s, "Delete", false); + let after = selected(&s); + assert_eq!(after.len(), 1, "one point selected after a plain Delete: {after:?}"); + assert!([Point::new(100.0, 100.0), Point::new(0.0, 0.0)].contains(&after[0]), "a neighbour of the deleted corner: {after:?}"); +} + #[test] fn handles_follow_their_mirroring() { // A smooth middle point at (100, 0) on an open path; one handle is dragged to (+30, 10). diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..ed3e32001 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (in vector edit mode, deleting a point selects the next one on its path, so Delete pressed again goes on along it; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-18 | patch | M8: in vector edit mode, deleting a selected point (Delete or Backspace, or Shift+Delete to heal) left nothing selected, so deleting several points along a path meant clicking each one first. The point that followed the deleted one along its path is now selected, the one before it when the deleted point ended the path, so Delete pressed again goes on along it; points and segments cut to the clipboard still leave nothing selected. Test: `vector_behaviour_tests::deleting_a_point_selects_the_next_one_on_its_path` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From ead7e5b39023187e168bbaf322ac13f4de233ada Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:28:20 -0500 Subject: [PATCH 04/36] M5: A clicked layer row leaves the arrow keys to the canvas A click on a row in the Layers panel gave the arrow keys to the rows: Up and Down walked the list and Left and Right opened and closed rows. A layer picked there couldn't be nudged, nor moved one place up or down its vertical auto layout frame, which is how designers reorder a column. In Figma a layer picked in the Layers panel moves with the arrows (the locked-layer rule measured on 2026-11-10 is that a locked one doesn't). The arrows now nudge after a row click, as on the canvas. Walking the rows with the arrows stays for the keyboard: F6 into the Layers panel puts the keyboard on the selected row (a11y::layer_row), which was already a path of its own. layers_focus still records the click, so Shift+F10 after it opens the menu at the row. The row-walking tests now reach the rows by F6, and the perf bench does the same. --- crates/ui-egui/src/layers_keys_tests.rs | 64 ++++++++++++++++++++----- crates/ui-egui/src/lib.rs | 5 +- crates/ui-egui/src/perf_tests.rs | 2 +- crates/ui-egui/src/shortcuts.rs | 4 -- docs/ui-parity.md | 3 +- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/layers_keys_tests.rs b/crates/ui-egui/src/layers_keys_tests.rs index cb9fe17cc..b89c03fcf 100644 --- a/crates/ui-egui/src/layers_keys_tests.rs +++ b/crates/ui-egui/src/layers_keys_tests.rs @@ -1,6 +1,7 @@ -//! Arrow keys in the layers panel once a row has been clicked: up/down through the rows (Shift -//! extends), left/right to collapse, expand, and go to the parent or first child; a press on the -//! canvas gives arrows back to nudging. Delete after a click in the Pages list deletes the page. +//! Arrow keys in the layers panel once F6 has put the keyboard on its rows: up/down through the +//! rows (Shift extends), left/right to collapse, expand, and go to the parent or first child. After +//! a click on a row the arrows nudge the layer, as on the canvas. Delete after a click in the Pages +//! list deletes the page. use egui::{Event, Key, Modifiers, Pos2, pos2, vec2}; use figcraft_doc::NodeId; @@ -46,10 +47,29 @@ fn click_row(u: &mut Ui, id: NodeId) { assert_eq!(sel(u), vec![id]); } +/// Presses F6 until the keyboard is on the layers panel, as a keyboard user gets there. +fn keyboard_into_the_layers(u: &mut Ui) { + for _ in 0..crate::a11y::Region::ALL.len() { + key(u, Key::F6, false); + u.frame(vec![]); + if u.app.ui.nav.region == crate::a11y::Region::Layers { + return; + } + } + panic!("F6 never reached the layers panel"); +} + +/// Selects `id` and moves the keyboard onto its row with F6. +fn keyboard_to_the_row(u: &mut Ui, id: NodeId) { + u.app.run("select.set", json!({"ids": [id]})); + u.frame(vec![]); + keyboard_into_the_layers(u); +} + #[test] fn up_and_down_walk_the_rows_and_shift_extends() { let (mut u, a, frame, _, c) = setup(); - click_row(&mut u, c); + keyboard_to_the_row(&mut u, c); key(&mut u, Key::ArrowDown, false); assert_eq!(sel(&u), vec![frame]); key(&mut u, Key::ArrowDown, false); @@ -103,6 +123,7 @@ fn a_keyboard_shift_range_keeps_an_anchor_covered_by_a_selected_frame() { let mut want = vec![rect4, frame1]; want.sort(); assert_eq!(got, want, "the pointer range keeps the frame"); + keyboard_into_the_layers(&mut u); // Rows: Frame 2, Rect 4, Frame 1, Rect 3, Rect 2. Shift+Down runs from Rect 2 (the anchor). key(&mut u, Key::ArrowDown, true); let mut got = sel(&u); @@ -115,7 +136,7 @@ fn a_keyboard_shift_range_keeps_an_anchor_covered_by_a_selected_frame() { #[test] fn left_and_right_open_close_and_move_between_levels() { let (mut u, _, frame, child, _) = setup(); - click_row(&mut u, frame); + keyboard_to_the_row(&mut u, frame); key(&mut u, Key::ArrowRight, false); assert!(u.app.ui.expanded.contains(&frame), "Right opens a closed row"); assert_eq!(sel(&u), vec![frame]); @@ -129,21 +150,38 @@ fn left_and_right_open_close_and_move_between_levels() { } #[test] -fn a_canvas_press_gives_arrows_back_to_nudging() { +fn a_clicked_row_leaves_the_arrows_to_the_canvas() { let (mut u, _, _, _, c) = setup(); click_row(&mut u, c); - assert!(u.app.ui.layers_focus); - // Press on empty canvas (deselects), then select c from the canvas side and nudge it. - let p = pos2(900.0, 700.0); - u.button(p, true); - u.button(p, false); - assert!(!u.app.ui.layers_focus); - u.app.run("select.set", json!({"ids": [c]})); key(&mut u, Key::ArrowRight, false); + assert_eq!(sel(&u), vec![c]); let doc = u.app.session.doc().unwrap(); assert_eq!(doc.node(c).unwrap().transform.translation().x, 201.0); } +#[test] +fn down_on_a_clicked_row_moves_it_one_place_in_a_vertical_auto_layout() { + let mut s = Session::new(); + let column = id(s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 100, "height": 200, "name": "Column"})).unwrap()); + let rows: Vec = (0..3) + .map(|i| id(s.execute("shape.rectangle", &json!({"x": 0, "y": i * 30, "width": 80, "height": 20, "parent": column})).unwrap())) + .collect(); + s.execute("layout.add", &json!({"ids": [column], "direction": "vertical"})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let mut u = Ui::new(s); + u.app.ui.expanded.insert(column); + u.frame(vec![]); + click_row(&mut u, rows[1]); + key(&mut u, Key::ArrowDown, false); + let order = u.app.session.doc().unwrap().node(column).unwrap().children.clone(); + assert_eq!(order, [rows[0], rows[2], rows[1]]); + assert_eq!(sel(&u), vec![rows[1]]); + key(&mut u, Key::ArrowUp, false); + key(&mut u, Key::ArrowUp, false); + let order = u.app.session.doc().unwrap().node(column).unwrap().children.clone(); + assert_eq!(order, [rows[1], rows[0], rows[2]]); +} + /// The middle of `page`'s row in the Pages list, found by clicking down the list until it opens; /// then back to `back`. fn page_row(u: &mut Ui, page: NodeId, back: NodeId) -> Pos2 { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 32d859f6c..88b173701 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -550,8 +550,9 @@ pub struct UiState { pub layer_search: bool, pub layer_filter: String, pub layer_anchor: Option, - /// The layers panel has the keyboard: arrow keys move through its rows instead of nudging - /// (set by a click on a row, cleared by a press on the canvas). + /// A layer row was clicked last: Shift+F10 opens the context menu at its row (set by a click on + /// a row, cleared by a press on the canvas). Arrow keys still nudge; they move through the rows + /// only once F6 has put the keyboard on the layers panel. pub layers_focus: bool, /// The file (its `uid`) whose pages list has the keyboard: Delete with no layers selected deletes /// its current page (set by a click on a page row or the add-page button, cleared by a click on a diff --git a/crates/ui-egui/src/perf_tests.rs b/crates/ui-egui/src/perf_tests.rs index eba5e68cd..bbcee8408 100644 --- a/crates/ui-egui/src/perf_tests.rs +++ b/crates/ui-egui/src/perf_tests.rs @@ -114,10 +114,10 @@ fn report(layers: usize) { let open: Vec = b.app.session.doc().unwrap().nodes().filter(|n| !n.children.is_empty()).map(|n| n.id).collect(); b.app.ui.expanded.extend(open); rows.push(("first frame, every layer expanded", b.frame(vec![]))); - b.app.ui.layers_focus = true; let top = b.app.session.doc().ok().and_then(|d| d.node(page)?.children.last().copied()); b.app.session.set_selection(top.into_iter().collect()); b.frame(vec![]); + b.frame(key(Key::F6, Modifiers::SHIFT)); rows.push(("arrow key down the expanded layers", b.mean(30, |_| key(Key::ArrowDown, Modifiers::NONE)))); b.app.ui.expanded.clear(); b.frame(vec![]); diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 1cac67b4b..a3e6a3ed3 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -476,10 +476,6 @@ fn key_event(app: &mut FigApp, key: Key, physical: Option, m: Modifiers, re } return true; } - // Arrows move through the layers panel while it has the keyboard. - if app.ui.layers_focus && !m.command && !m.alt && crate::layers::key_nav(app, key, m.shift) { - return true; - } // Arrow nudges, Alt held too (measuring stays on while the selection moves); with nothing // selected the arrows pan the view. let (dx, dy) = match key { diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..d560157c1 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (after a click on a layer row the arrow keys nudge the selection, or move a layer in an auto layout flow one place, as in Figma; the rows take the arrows once they have the keyboard (F6); Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-19 | patch | M5: a click on a row in the Layers panel gave the arrow keys to the rows, so Up and Down moved the selection through the list and Left and Right opened and closed rows. A layer picked there couldn't be nudged, nor moved up or down its vertical auto layout frame. As in Figma, where a locked layer picked in the Layers panel is the one the arrows don't move (row of 2026-11-10), a clicked row now leaves the arrows to the canvas. Walking the rows with the arrows is still there for the keyboard: F6 into the Layers panel puts the keyboard on the selected row. Shift+F10 after a click still opens the menu at the row. Tests: `layers_keys_tests::a_clicked_row_leaves_the_arrows_to_the_canvas`, `down_on_a_clicked_row_moves_it_one_place_in_a_vertical_auto_layout`; the row-walking tests now reach the rows by F6 | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 26860bd367bbb1e47b105fc1bd316c4e46f95c52 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:11:18 -0500 Subject: [PATCH 05/36] M1: A drag on a section's background, or an artboard's in it, draws a marquee The background of a top-level frame with layers already acted like the canvas: a press there starts a marquee inside it. A section and the frames in it got none of that, so a drag anywhere in a section with artboards picked up the section (or the artboard) and moved it, and nothing in it could be marked out with the pointer. - An unselected section with layers, and a frame with layers directly in a section, now act like a top-level frame's background: a click deselects, a drag draws a marquee. A section still moves by its name label, or by its body once selected. - A marquee started in a section selects among the section's layers as one started on the page does among the page's (artboards it encloses whole, else the layers it touches inside them); one started in an artboard in a section selects inside that artboard. - With Cmd/Ctrl held, a drag from such a background draws the deep marquee instead of moving the frame or section, selecting the nested layers it touches. This holds when the artboard or section is selected too: with Cmd/Ctrl its background counts as background, and the press doesn't fall back to dragging the selection. A Cmd/Ctrl click there without a drag still selects the frame or section, and without Cmd/Ctrl a selected section or artboard still drags by its body. The comment above board_background ("unless the frame is selected") still describes the press without Cmd/Ctrl. Tests: section_marquee_tests. --- crates/engine/src/canvas/tools/drag.rs | 26 +++-- crates/engine/src/canvas/tools/pointer.rs | 32 +++++- crates/engine/src/lib.rs | 2 + crates/engine/src/section_marquee_tests.rs | 115 +++++++++++++++++++++ docs/ui-parity.md | 3 +- 5 files changed, 168 insertions(+), 10 deletions(-) create mode 100644 crates/engine/src/section_marquee_tests.rs diff --git a/crates/engine/src/canvas/tools/drag.rs b/crates/engine/src/canvas/tools/drag.rs index 84ca02ba4..9b71c842d 100644 --- a/crates/engine/src/canvas/tools/drag.rs +++ b/crates/engine/src/canvas/tools/drag.rs @@ -79,15 +79,22 @@ impl Session { // layers in it is like the canvas (a press starts a marquee inside it) unless the frame is // selected; stepping out from a selected descendant is handled by the marquee below. // An empty frame (or a widget, or a board object such as a sticky) is picked and dragged. + let in_section = |n: &figcraft_doc::Node| n.parent.and_then(|p| doc.node(p)).is_some_and(|p| matches!(p.kind, NodeKind::Section { .. })); let board_background = |leaf: NodeId| { - !sel.contains(&leaf) + (ev.cmd || !sel.contains(&leaf)) && doc.node(leaf).is_some_and(|n| { - n.parent == Some(page) && n.kind.is_frame_like() && !n.children.is_empty() && !crate::widgets::is_widget(n) && !n.is_board_atom() + let board = match n.kind { + NodeKind::Section { contents_hidden } => !contents_hidden, + ref k => k.is_frame_like() && (n.parent == Some(page) || in_section(n)), + }; + board && !n.children.is_empty() && !crate::widgets::is_widget(n) && !n.is_board_atom() }) }; let label = label_at(&doc, page, &self.tool.labels, ev.p()); - let hit = label.or_else(|| self.hit(&doc, page, ev.p(), ev.tol() * 2.0)); - let target = label.or_else(|| hit.filter(|leaf| ev.cmd || !board_background(*leaf)).map(|leaf| select_target(&doc, leaf, &sel, ev.cmd))); + let leaf = self.hit(&doc, page, ev.p(), ev.tol() * 2.0); + let hit = label.or(leaf); + let background_under_cmd = leaf.filter(|l| ev.cmd && label.is_none() && board_background(*l)); + let target = label.or_else(|| leaf.filter(|leaf| !board_background(*leaf)).map(|leaf| select_target(&doc, leaf, &sel, ev.cmd))); // A press inside the selection's box that reaches nothing above it (an unfilled shape's // inside, the frame or canvas behind it, or a layer stacked below the selected layer the // press is in) drags the selection. In a gap between selected layers, what's there is hit. @@ -105,8 +112,15 @@ impl Session { // selects just it. A press that reaches nothing above the selection uses the selection as // its drag target instead; that fallback is not a clicked layer. let clicked = target; + let marks_out_a_selected_board = background_under_cmd.is_some_and(|b| sel.contains(&b)); let target = match sel.iter().copied().find(|s| !locked_in(&doc, *s)) { - Some(first) if label.is_none() && !ev.shift && behind_sel(target) && selection_box(&doc, &sel).is_some_and(|q| in_quad(&q, ev.p())) => { + Some(first) + if label.is_none() + && !ev.shift + && !marks_out_a_selected_board + && behind_sel(target) + && selection_box(&doc, &sel).is_some_and(|q| in_quad(&q, ev.p())) => + { Some(first) } _ => target, @@ -186,7 +200,7 @@ impl Session { if let Some(f) = parent { self.set_selection(vec![f]); } else if !ev.shift { - self.set_selection(vec![]); + self.set_selection(background_under_cmd.into_iter().collect()); } self.tool.gesture = Gesture::Marquee { start: ev.p(), diff --git a/crates/engine/src/canvas/tools/pointer.rs b/crates/engine/src/canvas/tools/pointer.rs index d7a40380e..b11d9fcb8 100644 --- a/crates/engine/src/canvas/tools/pointer.rs +++ b/crates/engine/src/canvas/tools/pointer.rs @@ -38,11 +38,34 @@ impl Session { /// (its children), or the focus view's frame. pub(crate) fn marquee_within(&self, p: Point) -> Result> { let (doc, page) = (self.doc()?, self.page()?); - let within = frame_at(doc, page, p, &[]).filter(|f| doc.node(*f).is_some_and(|n| n.parent == Some(page))); - let within = within.filter(|f| doc.world_bounds(*f).is_some_and(|b| b.contains(p))); + let deepest = frame_at(doc, page, p, &[]).filter(|f| doc.world_bounds(*f).is_some_and(|b| b.contains(p))); + let mut chain = deepest.map(|f| doc.ancestors(f)).unwrap_or_default(); + chain.reverse(); + chain.extend(deepest); + let mut within = None; + for c in chain.into_iter().filter(|c| *c != page) { + let Some(n) = doc.node(c) else { break }; + match &n.kind { + NodeKind::Section { contents_hidden: false } => within = Some(c), + k if k.is_frame_like() => { + within = Some(c); + break; + } + _ => break, + } + } Ok(self.ds()?.focused().or(within)) } + fn marquee_root(&self, within: Option) -> Result<(NodeId, Option)> { + let (doc, page) = (self.doc()?, self.page()?); + Ok(match within.and_then(|w| doc.node(w)) { + Some(n) if matches!(n.kind, NodeKind::Section { .. }) => (n.id, None), + Some(n) => (n.parent.unwrap_or(page), Some(n.id)), + None => (page, None), + }) + } + /// The selection a marquee over page rect `r` makes from `base` (what was selected before): /// the layers it touches (`deep`: nested ones too); `additive` (Shift) toggles them. pub(crate) fn marquee_selection(&self, r: Rect, within: Option, deep: bool, base: &[NodeId], additive: bool) -> Result> { @@ -51,7 +74,10 @@ impl Session { let mut hits = match (deep, focused) { (true, _) => figcraft_doc::geometry::marquee_deep(doc, page, r), (false, Some(f)) => figcraft_doc::geometry::marquee(doc, page, r, Some(f)), - (false, None) => figcraft_doc::geometry::marquee_select(doc, page, r, within), + (false, None) => { + let (root, start_inside) = self.marquee_root(within)?; + figcraft_doc::geometry::marquee_select(doc, root, r, start_inside) + } }; if let Some(f) = focused { hits.retain(|h| *h != f && doc.is_ancestor(f, *h)); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ad6bb085e..a0c161697 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -563,6 +563,8 @@ mod scaled_instance_tests; #[cfg(test)] mod section_contents_tests; #[cfg(test)] +mod section_marquee_tests; +#[cfg(test)] mod section_tests; #[cfg(test)] mod select_area_tests; diff --git a/crates/engine/src/section_marquee_tests.rs b/crates/engine/src/section_marquee_tests.rs new file mode 100644 index 000000000..566d21faf --- /dev/null +++ b/crates/engine/src/section_marquee_tests.rs @@ -0,0 +1,115 @@ +use figcraft_doc::NodeId; +use serde_json::{Value, json}; + +use crate::Session; +use crate::params::id_of; +use crate::tools::{PointerEvent, PointerKind}; + +fn ex(s: &mut Session, cmd: &str, p: Value) -> NodeId { + id_of(&s.execute(cmd, &p).unwrap_or_else(|e| panic!("{cmd}: {e}"))["id"]).unwrap() +} + +fn rect(s: &mut Session, x: f64, y: f64, parent: NodeId) -> NodeId { + ex(s, "shape.rectangle", json!({"x": x, "y": y, "width": 40, "height": 40, "parent": parent})) +} + +struct Scene { + section: NodeId, + left: NodeId, + right: NodeId, + in_left: [NodeId; 2], + in_right: NodeId, +} + +fn scene(s: &mut Session) -> Scene { + let section = ex(s, "node.create", json!({"type": "section", "x": 0, "y": 0, "width": 1000, "height": 600})); + let left = ex(s, "frame.create", json!({"x": 50, "y": 50, "width": 300, "height": 300, "parent": section})); + let right = ex(s, "frame.create", json!({"x": 400, "y": 50, "width": 300, "height": 300, "parent": section})); + let in_left = [rect(s, 20.0, 20.0, left), rect(s, 120.0, 120.0, left)]; + let in_right = rect(s, 20.0, 20.0, right); + s.execute("select.none", &json!({})).unwrap(); + Scene { section, left, right, in_left, in_right } +} + +fn ev(kind: PointerKind, p: (f64, f64), cmd: bool) -> PointerEvent { + PointerEvent { cmd, ..PointerEvent::at(kind, p.0, p.1, 1.0) } +} + +fn drag(s: &mut Session, a: (f64, f64), b: (f64, f64), cmd: bool) -> Vec { + s.pointer(&ev(PointerKind::Down, a, cmd)).unwrap(); + s.pointer(&ev(PointerKind::Move, b, cmd)).unwrap(); + s.pointer(&ev(PointerKind::Up, b, cmd)).unwrap(); + let mut sel = s.selection(); + sel.sort(); + sel +} + +fn x_of(s: &Session, id: NodeId) -> f64 { + s.doc().unwrap().world_bounds(id).unwrap().x0 +} + +fn sorted(mut v: Vec) -> Vec { + v.sort(); + v +} + +#[test] +fn a_drag_on_an_artboards_background_in_a_section_selects_what_it_touches() { + let mut s = Session::new(); + let k = scene(&mut s); + assert_eq!(drag(&mut s, (60.0, 60.0), (110.0, 110.0), false), vec![k.in_left[0]]); + assert_eq!(drag(&mut s, (340.0, 340.0), (60.0, 60.0), false), sorted(k.in_left.to_vec())); + assert_eq!((x_of(&s, k.section), x_of(&s, k.left)), (0.0, 50.0), "nothing moved"); +} + +#[test] +fn a_drag_on_a_sections_background_selects_the_artboards_layers_it_touches() { + let mut s = Session::new(); + let k = scene(&mut s); + assert_eq!(drag(&mut s, (20.0, 400.0), (480.0, 80.0), false), sorted(vec![k.in_left[0], k.in_left[1], k.in_right])); + assert_eq!(drag(&mut s, (20.0, 20.0), (720.0, 380.0), false), sorted(vec![k.left, k.right]), "artboards it encloses go whole"); + assert_eq!(x_of(&s, k.section), 0.0, "the section stays put"); +} + +#[test] +fn a_selected_section_still_drags_and_a_click_on_its_background_steps_out_to_it() { + let mut s = Session::new(); + let k = scene(&mut s); + s.execute("select.set", &json!({"ids": [k.section]})).unwrap(); + drag(&mut s, (20.0, 400.0), (120.0, 400.0), false); + assert_eq!(x_of(&s, k.section), 100.0); + s.execute("select.set", &json!({"ids": [k.in_right]})).unwrap(); + assert_eq!(drag(&mut s, (900.0, 500.0), (900.0, 500.0), false), vec![k.section]); +} + +#[test] +fn cmd_drag_from_a_background_marks_out_nested_layers_and_cmd_click_still_picks_the_frame() { + let mut s = Session::new(); + let k = scene(&mut s); + assert_eq!(drag(&mut s, (60.0, 60.0), (110.0, 110.0), true), vec![k.in_left[0]]); + assert_eq!(drag(&mut s, (20.0, 400.0), (480.0, 80.0), true), sorted(vec![k.in_left[0], k.in_left[1], k.in_right])); + assert_eq!((x_of(&s, k.section), x_of(&s, k.left)), (0.0, 50.0), "nothing moved"); + assert_eq!(drag(&mut s, (300.0, 300.0), (300.0, 300.0), true), vec![k.left]); + assert_eq!(drag(&mut s, (900.0, 500.0), (900.0, 500.0), true), vec![k.section]); +} + +#[test] +fn cmd_drag_inside_a_selected_artboard_or_section_marks_out_nested_layers_instead_of_moving_it() { + let mut s = Session::new(); + let k = scene(&mut s); + s.execute("select.set", &json!({"ids": [k.left]})).unwrap(); + assert_eq!(drag(&mut s, (130.0, 75.0), (90.0, 90.0), true), vec![k.in_left[0]]); + s.execute("select.set", &json!({"ids": [k.section]})).unwrap(); + assert_eq!(drag(&mut s, (20.0, 400.0), (480.0, 80.0), true), sorted(vec![k.in_left[0], k.in_left[1], k.in_right])); + assert_eq!((x_of(&s, k.section), x_of(&s, k.left)), (0.0, 50.0), "nothing moved"); + s.execute("select.set", &json!({"ids": [k.left]})).unwrap(); + assert_eq!(drag(&mut s, (300.0, 300.0), (300.0, 300.0), true), vec![k.left], "a Cmd click keeps the artboard"); + assert_eq!(drag(&mut s, (80.0, 80.0), (80.0, 80.0), true), vec![k.in_left[0]], "a Cmd click on a layer in it picks the layer"); + + let mut s = Session::new(); + let board = ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 400, "height": 400})); + let inner = [rect(&mut s, 20.0, 20.0, board), rect(&mut s, 200.0, 200.0, board)]; + s.execute("select.set", &json!({"ids": [board]})).unwrap(); + assert_eq!(drag(&mut s, (330.0, 30.0), (10.0, 300.0), true), sorted(inner.to_vec()), "a top-level artboard too"); + assert_eq!(x_of(&s, board), 0.0); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..9cfb29f3d 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (M1: a drag on a section's background, or on the background of a frame in it, draws a marquee; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-15 | patch | M1: in a section, a press on the section's background or on the background of a frame in it picked up the section or the frame, so a drag moved it and nothing inside could be marked out. An unselected section with layers, and a frame with layers directly in a section, now act like a top-level frame's background: a click deselects and a drag draws a marquee. The marquee selects among the section's layers as one on the page does among the page's, or inside the frame it starts in. With Cmd/Ctrl held the drag draws the deep marquee, on a selected artboard or section too instead of moving it; a Cmd/Ctrl click without a drag still selects the frame or section. A section moves by its name label, or by its body once selected. Test: `section_marquee_tests` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 85de85d5692f63d00a7264353b3a70ef5f01670a Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:27:42 -0500 Subject: [PATCH 06/36] M3: Paste with a variant's set selected adds the copied variants to it Copying a variant and pasting with that variant, a layer in it or its set selected pasted an instance on the page: the set was not a place paste could put layers, and a copied main component pastes as an instance of it. Copied variants of one set now paste into that set as new variants (deep copies, like Duplicate makes), under the copied variants where they are now and below the lowest variant with a gap of 20 as Add variant places one, and the set grows to hold them. Only a plain edit.paste with the copied variants' own set, or a layer in it, selected does this: paste decides it and passes it to paste_into's worker, which also checks the target is that set. Inferring it from the parent being a component set made copies of the mains for every other paste into a set too. Those keep making instances: a variant pasted with another set selected, a main that is no variant pasted with a set selected, Paste over and Paste to replace on a sibling variant, and an explicit parent, even the variant's own set. Each has a test. copying_a_variant_pastes_an_instance_but_copying_its_set_keeps_the_components now pastes with nothing selected for its instance case. --- crates/engine/src/cmd/component.rs | 1 + crates/engine/src/cmd/component/variants.rs | 2 +- crates/engine/src/cmd/edit/clipboard.rs | 38 ++++++- .../engine/src/components_behaviour_tests.rs | 103 ++++++++++++++++++ docs/components-parity.md | 5 +- 5 files changed, 144 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rs index f68fac714..c726613b3 100644 --- a/crates/engine/src/cmd/component.rs +++ b/crates/engine/src/cmd/component.rs @@ -24,6 +24,7 @@ use instance::{detach, make_slot, push_changes, remove_slot, reset_instance, res pub(crate) use instance::{swap_at, swap_instance}; use props::{add_prop, bind_prop, delete_prop, edit_prop, set_props}; pub(crate) use props::{apply_prop_bindings, check_prop_binding, describe_props}; +pub(crate) use variants::fit_set; use variants::{add_variant, combine, create_set}; pub use variants::{can_add_variant, can_combine_variants, can_create_set}; diff --git a/crates/engine/src/cmd/component/variants.rs b/crates/engine/src/cmd/component/variants.rs index be43bced0..3125daf12 100644 --- a/crates/engine/src/cmd/component/variants.rs +++ b/crates/engine/src/cmd/component/variants.rs @@ -166,7 +166,7 @@ pub(super) fn create_set(s: &mut Session, p: &Value) -> Result { } /// Grow a component set so it wraps its variants with 20 px of padding (right and bottom). -pub(super) fn fit_set(doc: &mut Document, set: NodeId) { +pub(crate) fn fit_set(doc: &mut Document, set: NodeId) { let Some(kids) = doc.node(set).map(|n| n.children.clone()) else { return }; let (mut w, mut h) = (0.0f64, 0.0f64); for c in kids { diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 09c79190b..98d3eff25 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -221,6 +221,14 @@ pub(super) fn cut(s: &mut Session, p: &Value) -> Result { /// Paste the clipboard under `parent` with the copied top-left moved to `at` (page coords). pub fn paste_into(s: &mut Session, parent: NodeId, at: Option<(f64, f64)>) -> Result> { + paste_layers(s, parent, at, false) +} + +/// [`paste_into`]. With `as_variants`, copied variants pasted into `parent`, their own set, are +/// deep copies (new variants, as Duplicate makes) and the set grows to hold them. Only a plain +/// paste with that set, or a layer in it, selected asks for this; every other paste of a copied +/// main, into another set too, still makes an instance. +fn paste_layers(s: &mut Session, parent: NodeId, at: Option<(f64, f64)>, as_variants: bool) -> Result> { let clip = s.clipboard.clone(); if clip.nodes.is_empty() { return Err(EngineError::Disabled("edit.paste".into(), "the clipboard is empty".into())); @@ -238,10 +246,12 @@ pub fn paste_into(s: &mut Session, parent: NodeId, at: Option<(f64, f64)>) -> Re (Some((x, y)), Some(b)) => Affine::translate((x - b.x0, y - b.y0)), _ => Affine::IDENTITY, }; + let into_set = as_variants && copy_local && copied_variants_set(doc, &clip.nodes) == Some(parent); let mut out = Vec::new(); let mut all = BTreeMap::new(); for (root, nodes) in &clip.nodes { if copy_local + && !into_set && clip.copied_components.contains(root) && let Some(n) = nodes.first().filter(|n| matches!(n.kind, NodeKind::Component { .. })) && doc.node(*root).is_some_and(|n| matches!(n.kind, NodeKind::Component { .. })) @@ -264,6 +274,9 @@ pub fn paste_into(s: &mut Session, parent: NodeId, at: Option<(f64, f64)>) -> Re out.push(doc.paste_nodes(&nodes, &map, *root, into, None)?); all.extend(map); } + if into_set { + crate::cmd::component::fit_set(doc, parent); + } // Board connectors pasted with what they join join the pasted copies. let originals: Vec<(NodeId, figcraft_doc::BoardItem)> = clip.nodes.iter().flat_map(|(_, nodes)| nodes).filter_map(|n| Some((*all.get(&n.id)?, n.board.clone()?))).collect(); @@ -286,7 +299,16 @@ pub(super) fn paste(s: &mut Session, p: &Value) -> Result { let sel = s.selection(); let doc = s.doc()?; let copy_local = s.ds()?.uid == s.clipboard.source_doc; - let target = id(p, "parent").or_else(|| { + let variants_set = copied_variants_set(doc, &s.clipboard.nodes) + .filter(|set| copy_local && id(p, "parent").is_none() && !sel.is_empty() && sel.iter().all(|i| doc.is_ancestor(*set, *i))); + // Where the copied variants are now, not where they were copied: the set may have moved since. + let below_the_variants = variants_set.and_then(|set| { + let copied: Vec = s.clipboard.nodes.iter().map(|(root, _)| *root).collect(); + let left = doc.bounds_of(&copied)?.x0; + let bottom = doc.node(set)?.children.iter().filter_map(|c| doc.world_bounds(*c)).map(|r| r.y1).reduce(f64::max)?; + Some((left, bottom + 20.0)) + }); + let target = id(p, "parent").or(variants_set).or_else(|| { sel.first() .copied() .filter(|i| { @@ -301,6 +323,7 @@ pub(super) fn paste(s: &mut Session, p: &Value) -> Result { let parent = target.unwrap_or(page); let at = match (num(p, "x"), num(p, "y")) { (Some(x), Some(y)) => Some((x, y)), + _ if below_the_variants.is_some() => below_the_variants, _ => { let b = s.clipboard.bounds; match (target, b) { @@ -323,7 +346,7 @@ pub(super) fn paste(s: &mut Session, p: &Value) -> Result { } } }; - let ids = paste_into(s, parent, at)?; + let ids = paste_layers(s, parent, at, variants_set.is_some())?; if let Some(sel) = sibling_of { let above = s.doc()?.index_in_parent(sel).map(|ix| ix + 1); move_above(s, &ids, parent, above)?; @@ -360,6 +383,17 @@ fn move_above(s: &mut Session, ids: &[NodeId], parent: NodeId, above: Option)]) -> Option { + let mut sets = copied.iter().map(|(root, _)| { + let n = doc.node(*root).filter(|n| matches!(n.kind, NodeKind::Component { .. }))?; + n.parent.filter(|set| doc.node(*set).is_some_and(|p| matches!(p.kind, NodeKind::ComponentSet { .. }))) + }); + let first = sets.next()??; + sets.all(|set| set == Some(first)).then_some(first) +} + pub(super) fn paste_over(s: &mut Session, _p: &Value) -> Result { let sel = s.selection(); let page = s.page()?; diff --git a/crates/engine/src/components_behaviour_tests.rs b/crates/engine/src/components_behaviour_tests.rs index e8dda9e95..6cc3a7e85 100644 --- a/crates/engine/src/components_behaviour_tests.rs +++ b/crates/engine/src/components_behaviour_tests.rs @@ -115,6 +115,7 @@ fn copying_a_variant_pastes_an_instance_but_copying_its_set_keeps_the_components let (set, _, hover) = button_set(&mut s); ex(&mut s, "select.set", json!({"ids": [hover]})); ex(&mut s, "edit.copy", json!({})); + ex(&mut s, "select.set", json!({"ids": []})); let pasted = crate::params::id_of(&ex(&mut s, "edit.paste", json!({}))["ids"][0]).unwrap(); assert_eq!(component_of(&s, pasted), hover); assert_eq!(node(&s, pasted).name, node(&s, set).name); @@ -241,6 +242,108 @@ fn alt_dragging_a_main_component_copies_an_instance() { healthy(&s); } +#[test] +fn pasting_a_variant_with_its_set_selected_adds_a_variant_below_the_others() { + let mut s = Session::new(); + let (set, _, hover) = button_set(&mut s); + let bounds = |s: &Session, i: NodeId| s.doc().unwrap().world_bounds(i).unwrap(); + let named = |s: &Session, i: NodeId, name: &str| kids(s, i).into_iter().find(|c| node(s, *c).name == name).unwrap(); + ex(&mut s, "select.set", json!({"ids": [hover]})); + ex(&mut s, "edit.copy", json!({})); + let bottom = kids(&s, set).iter().map(|k| bounds(&s, *k).y1).fold(f64::MIN, f64::max); + let pasted = crate::params::id_of(&ex(&mut s, "edit.paste", json!({}))["ids"][0]).unwrap(); + assert!(matches!(node(&s, pasted).kind, NodeKind::Component { .. })); + assert_eq!(node(&s, pasted).parent, Some(set)); + assert_eq!(kids(&s, set).len(), 3); + assert_eq!(chars(&s, named(&s, pasted, "Label")), "Hover"); + let (b, h) = (bounds(&s, pasted), bounds(&s, hover)); + assert_eq!((b.x0, b.y0), (h.x0, bottom + 20.0)); + assert!(bounds(&s, set).y1 >= b.y1, "the set grows to hold it"); + + let label = named(&s, hover, "Label"); + ex(&mut s, "select.set", json!({"ids": [label]})); + let second = crate::params::id_of(&ex(&mut s, "edit.paste", json!({}))["ids"][0]).unwrap(); + assert_eq!(node(&s, second).parent, Some(set), "a layer inside a variant selected"); + assert_eq!(bounds(&s, second).y0, b.y1 + 20.0); + ex(&mut s, "edit.undo", json!({})); + assert_eq!(kids(&s, set).len(), 3); + healthy(&s); +} + +#[test] +fn a_variant_pasted_into_its_set_after_the_set_moved_lands_under_the_variant() { + let mut s = Session::new(); + let (set, _, hover) = button_set(&mut s); + let bounds = |s: &Session, i: NodeId| s.doc().unwrap().world_bounds(i).unwrap(); + ex(&mut s, "select.set", json!({"ids": [hover]})); + ex(&mut s, "edit.copy", json!({})); + let x = bounds(&s, set).x0; + ex(&mut s, "node.set", json!({"id": set, "props": {"x": x + 1000.0}})); + let pasted = crate::params::id_of(&ex(&mut s, "edit.paste", json!({}))["ids"][0]).unwrap(); + let (b, h, sb) = (bounds(&s, pasted), bounds(&s, hover), bounds(&s, set)); + assert_eq!(b.x0, h.x0, "under the copied variant where it is now, not where it was copied"); + assert!(sb.x0 <= b.x0 && sb.x1 >= b.x1 && sb.y1 >= b.y1, "inside the set"); + healthy(&s); +} + +/// Copy `main`, select `selected` and run `command` with `params`; the first pasted layer. +fn copy_then(s: &mut Session, main: NodeId, selected: &[NodeId], command: &str, params: Value) -> NodeId { + ex(s, "select.set", json!({"ids": [main]})); + ex(s, "edit.copy", json!({})); + ex(s, "select.set", json!({"ids": selected})); + crate::params::id_of(&ex(s, command, params)["ids"][0]).unwrap() +} + +// Only a plain paste with the copied variants' own set, or a layer in it, selected makes new +// variants. Every other paste of a copied main into a set makes an instance of it there, as +// before: the tests below. + +#[test] +fn a_variant_pasted_with_another_set_selected_is_an_instance() { + let mut s = Session::new(); + let (set, _, hover) = button_set(&mut s); + let (other, ..) = button_set(&mut s); + ex(&mut s, "node.set", json!({"id": other, "props": {"y": 300}})); + let pasted = copy_then(&mut s, hover, &[other], "edit.paste", json!({})); + assert_eq!(component_of(&s, pasted), hover); + assert_eq!(node(&s, pasted).parent, Some(other)); + assert_eq!((kids(&s, set).len(), kids(&s, other).len()), (2, 3)); + healthy(&s); +} + +#[test] +fn a_main_that_is_no_variant_pasted_with_a_set_selected_is_an_instance() { + let mut s = Session::new(); + let (set, ..) = button_set(&mut s); + let k = kit(&mut s); + let pasted = copy_then(&mut s, k.card, &[set], "edit.paste", json!({})); + assert_eq!(component_of(&s, pasted), k.card); + assert_eq!(node(&s, pasted).parent, Some(set)); + healthy(&s); +} + +#[test] +fn a_variant_pasted_with_its_own_set_as_an_explicit_parent_is_an_instance() { + let mut s = Session::new(); + let (set, _, hover) = button_set(&mut s); + let pasted = copy_then(&mut s, hover, &[hover], "edit.paste", json!({"parent": set})); + assert_eq!(component_of(&s, pasted), hover); + assert_eq!(node(&s, pasted).parent, Some(set)); + healthy(&s); +} + +#[test] +fn pasting_over_or_replacing_a_variant_makes_an_instance_of_the_copied_variant() { + for command in ["edit.pasteOver", "edit.pasteReplace"] { + let mut s = Session::new(); + let (set, default, hover) = button_set(&mut s); + let pasted = copy_then(&mut s, hover, &[default], command, json!({})); + assert_eq!(component_of(&s, pasted), hover, "{command} on a variant of the copied variant's set"); + assert_eq!(node(&s, pasted).parent, Some(set), "{command}"); + healthy(&s); + } +} + #[test] fn duplicating_a_variant_adds_a_variant_to_its_set() { let mut s = Session::new(); diff --git a/docs/components-parity.md b/docs/components-parity.md index fa4d2494e..b5df94b71 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (copied variants pasted with their own set, or a layer in it, selected join the set as new variants; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -18,7 +18,7 @@ accounts). | What an instance overrides: fills, strokes, effects, visibility, layer names, text content and every text property (resizing included), auto layout padding, gap and alignment, layout grids, export settings, prototype interactions, nested swaps and property values; the size and resizing (hug, fill, fixed, min and max) of layers inside it; an instance's own resizing (hug or fixed) follows its main's unless its size is overridden, measured: a plain instance turns Fixed when its main does (a child set to Fill along the hugging axis) and back to Hug with it, one whose width was typed keeps it, and Fill in its own auto layout parent is its own | done | each kept when the main changes that property, reset per group; opacity and corner radius too (documentation silent); size and resizing are kept through relayout, undo, save, `.fig` and REST import and detach, and stay with the instance on push | | What it doesn't: position, rotation, constraints and absolute or grid placement of layers inside it, its auto layout direction and other settings, its structure | done | refused with a message, the fields greyed out (Delete on a layer inside an instance hides it instead of removing it, as the help center says it does); the instance itself resizes and its layers follow the main's constraints | | Component sets / variants, add variant, switch | done | Combine as variants is in the Object menu, and the canvas and layers context menu and the Design panel offer it when two or more main components are selected; Add variant on a main component not in a set yet makes it a set of itself and the new variant, one undo step (#903); components that are variants already aren't combined again (it used to put a set inside a set); combining gives every variant the component properties any of them had, so another variant's layers can be bound to one made before combining | -| A main's copy within its file is an instance of it: Duplicate, Alt-drag, Copy then Paste | done | a variant duplicated in its set stays a new variant and a whole set copies as a new set; only the copied roots become instances (a main inside a copied frame is copied as a main); Cut then Paste and pastes into other files keep the component (#892) | +| A main's copy within its file is an instance of it: Duplicate, Alt-drag, Copy then Paste | done | a variant duplicated in its set stays a new variant and a whole set copies as a new set; only the copied roots become instances (a main inside a copied frame is copied as a main); Cut then Paste and pastes into other files keep the component (#892); copied variants pasted with their own set, or a variant or layer in it, selected join the set as new variants, while other pastes into a set, Paste over and Paste to replace still make an instance | | A component can't contain its own instance, directly or through other components | done | refused with the loop named (creating, placing, swapping, switching variants, moving, pasting, an instance-swap value); each variant counts as its own component, so a variant may hold a sibling variant's instance unless that one leads back to it; a dropped instance lands on the page; a file holding a loop opens with one instance detached and a note, any other file unchanged; a loop merged in a live session stops expanding where an instance would show itself again (#1084) | | Switching variants keeps overrides where names match and both variants had the same value; text layers keep theirs | done | | | Default variant: the top-left one (new instances, Assets thumbnail, generated code) | done | | @@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Date | Change | Summary | |---|---|---| +| 2026-11-19 | patch | M3: copying a variant and pasting with that variant, a layer in it or its set selected pasted an instance on the page. Copied variants of one set now paste into that set as new variants (deep copies, as Duplicate makes), under the copied variants where they are now, below the lowest variant with the gap of 20 that Add variant leaves, and the set grows to hold them. Every other paste of a copied main still makes an instance: with nothing selected, into another set, a main that isn't a variant pasted with a set selected, Paste over and Paste to replace on a variant, and an explicit `parent` (even the variant's own set). Tests: `pasting_a_variant_with_its_set_selected_adds_a_variant_below_the_others`, `a_variant_pasted_into_its_set_after_the_set_moved_lands_under_the_variant`, `a_variant_pasted_with_another_set_selected_is_an_instance`, `a_main_that_is_no_variant_pasted_with_a_set_selected_is_an_instance`, `a_variant_pasted_with_its_own_set_as_an_explicit_parent_is_an_instance`, `pasting_over_or_replacing_a_variant_makes_an_instance_of_the_copied_variant` | | 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`::S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. | | 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. | | 2026-11-18 | minor | M3, gap 10: library analytics count insertions and detachments of styles and variables. Applying one, or copying or duplicating content that uses it, inserts it; the Detach button detaches it; an instance counts as its component alone. Show usage and `library.usage` give them per style and variable over the chosen period. Modes aren't counted. Numbers unchanged. Tests: `library_asset_counts_tests`, `library_assets_tests`. | From 807d78b86d60d84c0b6b4fd92ceca839b483ffd9 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 00:46:54 -0500 Subject: [PATCH 07/36] M3: A binding the main layer doesn't have stays an override when instances are relinked Linking imported instances to their mains (and detaching an outer instance, or restoring a main) finds overrides by comparing each layer with its main layer, and compared values only. A layer bound to a variable its main layer doesn't bind, resolving to the main's colour, therefore wasn't an override. The next copy or edit of the main reset it to the main's unbound paint: in a file using a library, a button's icon lost the colour variable the library's button gave it, while the label next to it, whose main binds the variable, kept it. rebase_instance now adds the groups whose bindings differ from the main layer's (diff::rebound_groups), as record_overrides already did for a binding made in an instance. record_overrides no longer clears such an override when an edit sets the value back to the main's (hiding and showing the fill). Bindings are compared by what they bind, so `fill` and `fills/0/color` are one binding. --- crates/engine/src/assets/components.rs | 2 + crates/engine/src/assets/components/diff.rs | 32 ++++++++++++ .../assets/components/nested_binding_tests.rs | 51 +++++++++++++++++++ crates/engine/src/assets/components/patch.rs | 11 ++-- crates/engine/src/assets/components/rebase.rs | 4 +- docs/components-parity.md | 3 +- 6 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 crates/engine/src/assets/components/nested_binding_tests.rs diff --git a/crates/engine/src/assets/components.rs b/crates/engine/src/assets/components.rs index 06c82563a..80108045d 100644 --- a/crates/engine/src/assets/components.rs +++ b/crates/engine/src/assets/components.rs @@ -338,6 +338,8 @@ pub fn prop_default_value(d: &PropDef) -> Value { } } +#[cfg(test)] +mod nested_binding_tests; #[cfg(test)] mod rebase_source_tests; diff --git a/crates/engine/src/assets/components/diff.rs b/crates/engine/src/assets/components/diff.rs index 5c6b7e4c5..9102a38d6 100644 --- a/crates/engine/src/assets/components/diff.rs +++ b/crates/engine/src/assets/components/diff.rs @@ -35,6 +35,38 @@ pub(super) fn bindings_of<'a>(n: &'a Node, g: &'a str) -> impl Iterator bool { + let canonical = |m: &Node| -> std::collections::BTreeSet<(String, String)> { + bindings_of(m, g) + .map(|(k, v)| { + let key = crate::cmd::lists::list_binding(k).map_or_else(|| k.clone(), |(l, i, f)| format!("{}/{i}/{f}", l.prefix())); + (key, v.clone()) + }) + .collect() + }; + canonical(n) != canonical(src) +} + +/// The property groups whose variable bindings differ between layer `n` and its main layer `src`: +/// overrides even where both resolve to the same value. +pub(super) fn rebound_groups(n: &Node, src: &Node) -> Vec<&'static str> { + let mut compared = Vec::new(); + let mut out = Vec::new(); + for k in n.bound.keys().chain(src.bound.keys()) { + let Some(g) = binding_group(k) else { continue }; + if compared.contains(&g) { + continue; + } + compared.push(g); + if bound_differently(n, src, g) { + out.push(g); + } + } + out +} + /// Property groups that differ between two versions of a node. pub fn diff_groups(a: &Node, b: &Node) -> Vec<&'static str> { let mut out = Vec::new(); diff --git a/crates/engine/src/assets/components/nested_binding_tests.rs b/crates/engine/src/assets/components/nested_binding_tests.rs new file mode 100644 index 000000000..035014dcf --- /dev/null +++ b/crates/engine/src/assets/components/nested_binding_tests.rs @@ -0,0 +1,51 @@ +use serde_json::json; + +use super::rebase_instance; +use super::tests::{button, copy_of, ex, fill, idv, node}; +use crate::{NodeId, Session}; + +fn bound_shape_in_button() -> (Session, NodeId, NodeId, NodeId, NodeId) { + let mut s = Session::new(); + let (_, shape, button, nested) = button(&mut s); + ex(&mut s, "variable.createCollection", json!({"name": "T"})); + ex(&mut s, "variable.create", json!({"collection": "T", "name": "ink", "type": "color", "value": "#111111"})); + let inner = copy_of(&s, nested, shape); + ex(&mut s, "variable.bind", json!({"ids": [inner.0], "field": "fill", "variable": "ink"})); + assert!(node(&s, inner).overrides.contains("fills")); + (s, shape, button, nested, inner) +} + +#[test] +fn relinking_an_instance_keeps_a_binding_its_main_lacks_as_an_override() { + let (mut s, shape, button, nested, inner) = bound_shape_in_button(); + let doc = s.ds_mut().unwrap().doc_mut(); + doc.get_mut(inner).unwrap().overrides.clear(); + rebase_instance(doc, nested); + assert!(node(&s, inner).overrides.contains("fills"), "the same colour from a variable the main doesn't bind"); + ex(&mut s, "node.set", json!({"id": shape, "props": {"fill": "#FF0000"}})); + assert_eq!(fill(&s, inner), "111111", "an edit of the icon's main leaves the bound colour"); + let placed = idv(&ex(&mut s, "instance.create", json!({"component": button, "x": 400, "y": 400}))); + let copy = copy_of(&s, placed, inner); + assert_eq!(node(&s, copy).bound.values().collect::>(), [&node(&s, inner).bound["fill"]]); +} + +#[test] +fn hiding_and_showing_a_bound_fill_keeps_its_override() { + let (mut s, _, _, _, inner) = bound_shape_in_button(); + ex(&mut s, "fill.set", json!({"ids": [inner.0], "index": 0, "visible": false})); + ex(&mut s, "fill.set", json!({"ids": [inner.0], "index": 0, "visible": true})); + let n = node(&s, inner); + assert!(n.bound.contains_key("fill")); + assert!(n.overrides.contains("fills"), "the binding still differs from the main's"); +} + +#[test] +fn a_top_level_instance_s_own_resizing_binding_is_not_an_override() { + let mut s = Session::new(); + let (_, _, button, _) = button(&mut s); + let placed = idv(&ex(&mut s, "instance.create", json!({"component": button, "x": 400, "y": 400}))); + let doc = s.ds_mut().unwrap().doc_mut(); + doc.get_mut(placed).unwrap().bound.insert("minWidth".into(), "VariableID:1:1".into()); + rebase_instance(doc, placed); + assert!(!node(&s, placed).overrides.contains("resizing"), "a top-level instance's resizing is its own"); +} diff --git a/crates/engine/src/assets/components/patch.rs b/crates/engine/src/assets/components/patch.rs index 92d2e2f29..1b275721b 100644 --- a/crates/engine/src/assets/components/patch.rs +++ b/crates/engine/src/assets/components/patch.rs @@ -1,4 +1,4 @@ -use super::diff::{binding_group, bindings_of, diff_groups, follow_boolean_defaults, geometry_derived, variable_groups}; +use super::diff::{binding_group, bound_differently, diff_groups, follow_boolean_defaults, geometry_derived, rebound_groups, variable_groups}; use super::guard::{own_slot_content, relink_copy}; use super::instances::{copy_group, field_group, sync_instance}; use super::sync::insert_linked; @@ -179,12 +179,17 @@ fn override_groups(doc: &Document, before: &Document, id: NodeId, n: &Node, b: & // Binding another variable (or none) where the main binds one is an override. for (k, _) in b.bound.iter().chain(n.bound.iter()) { let Some(g) = binding_group(k) else { continue }; - let rebound = b.bound.get(k) != n.bound.get(k) && !bindings_of(n, g).eq(bindings_of(src, g)); + let rebound = b.bound.get(k) != n.bound.get(k) && bound_differently(n, src, g); if rebound && !groups.contains(&g) { groups.push(g); } } - cleared = raw.iter().filter(|g| !matches!(**g, "size" | "position") && !differs.contains(g) && n.overrides.contains(**g)).copied().collect(); + let rebound = rebound_groups(n, src); + cleared = raw + .iter() + .filter(|g| !matches!(**g, "size" | "position") && !differs.contains(g) && !rebound.contains(g) && n.overrides.contains(**g)) + .copied() + .collect(); if top_root { cleared.retain(|g| !matches!(*g, "component" | "props")); } diff --git a/crates/engine/src/assets/components/rebase.rs b/crates/engine/src/assets/components/rebase.rs index aa782cb20..b8a6c67c7 100644 --- a/crates/engine/src/assets/components/rebase.rs +++ b/crates/engine/src/assets/components/rebase.rs @@ -1,4 +1,4 @@ -use super::diff::{diff_groups, variable_groups}; +use super::diff::{diff_groups, rebound_groups, variable_groups}; use super::instances::{field_group, path_map}; use super::{BTreeMap, BTreeSet, Document, MAX_DEPTH, Node, NodeId, NodeKind, default_instance_name, holds_content}; @@ -216,6 +216,7 @@ pub fn rebase_instance_with(doc: &mut Document, inst: NodeId, mains: &mut MainPa let mut bound: Vec<&str> = m.prop_refs.keys().map(|f| field_group(f)).collect(); bound.extend(variable_groups(n, m)); overrides.extend(value_groups(m, n).into_iter().filter(|g| !bound.contains(&g.as_str()))); + overrides.extend(rebound_groups(n, m).into_iter().map(str::to_string)); if matches!((&m.kind, &n.kind), (NodeKind::Instance { component: a, .. }, NodeKind::Instance { component: b, .. }) if a != b) { overrides.insert("component".into()); } @@ -233,6 +234,7 @@ pub fn rebase_instance_with(doc: &mut Document, inst: NodeId, mains: &mut MainPa let mut groups: Vec = value_groups(m, n) .into_iter() .filter(|g| !matches!(g.as_str(), "name" | "exports" | "interactions") && !from_variables.contains(&g.as_str())) + .chain(rebound_groups(n, m).into_iter().map(str::to_string)) .filter(|g| placed_source.is_some() || !matches!(g.as_str(), "resizing" | "modes")) .collect(); let named = if placed_source.is_some() { n.name != m.name } else { n.name != default_instance_name(doc, component) }; diff --git a/docs/components-parity.md b/docs/components-parity.md index fa4d2494e..2e97e1415 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a layer inside an instance bound to a variable its main layer doesn't bind keeps that binding as an override when instances are relinked after an import, a detach or a restore, and when its value is set back to the main's, so a library copy or an edit of the main no longer drops it; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Date | Change | Summary | |---|---|---| +| 2026-11-19 | patch | M3: overrides found by comparing a layer with its main (`rebase_instance`: linking instances after a Figma or REST import, detaching an outer instance, restoring a main) counted values only, so a layer bound to a variable the main layer doesn't bind, resolving to the main's colour, wasn't an override; the next copy or edit of the main (a library update reaching another file) reset it to the main's unbound paint. Icons inside buttons of a design system imported from Figma lost their colour variable this way in the files using it. A binding that differs from the main's is now an override there, and an edit that sets the value back to the main's (hiding and showing the fill) no longer clears an override the binding still makes; `fill` and `fills/0/color` count as one binding. Tests: `nested_binding_tests` | | 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`::S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. | | 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. | | 2026-11-18 | minor | M3, gap 10: library analytics count insertions and detachments of styles and variables. Applying one, or copying or duplicating content that uses it, inserts it; the Detach button detaches it; an instance counts as its component alone. Show usage and `library.usage` give them per style and variable over the chosen period. Modes aren't counted. Numbers unchanged. Tests: `library_asset_counts_tests`, `library_assets_tests`. | From 6c590e4e8913721a9484fe06077fc13c4cf2b856 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:41:56 -0500 Subject: [PATCH 08/36] M3: Several selected instances show and set the properties they share With two or more instances selected the Design panel showed no instance properties, so changing a variant or a property meant selecting each instance in turn. instance.setProperties already took several ids. The panel now shows the variant, boolean, text and instance-swap properties the selected instances share, matched by name and type. A variant property lists only the values every one of their sets has, so the command can't be refused for one of them. Where the values differ the row reads Mixed (a dropdown's label, the text field's placeholder, the checkbox's third state), and a value chosen there is set on every selected instance in one step. A selection with any layer that isn't an instance shows none of this. Slots are filled one instance at a time, so their rows show only for one. A single instance goes through the same code with one id. One difference: a single instance's slot property whose slot can't be found now shows no row, where it showed a label with nothing beside it. swap_dropdown takes `mixed` to label such a row. A text field that reads Mixed changes nothing when committed empty: the field reports its text on every Enter or focus loss, edited or not, so an empty commit there can't be told from a click in and out. --- .../src/instances_shared_props_tests.rs | 77 ++++++++ crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/panels/component_panel.rs | 173 +++++++++++++----- crates/ui-egui/src/panels/dev_mode.rs | 3 +- docs/components-parity.md | 3 +- 5 files changed, 215 insertions(+), 43 deletions(-) create mode 100644 crates/ui-egui/src/instances_shared_props_tests.rs diff --git a/crates/ui-egui/src/instances_shared_props_tests.rs b/crates/ui-egui/src/instances_shared_props_tests.rs new file mode 100644 index 000000000..225fc184c --- /dev/null +++ b/crates/ui-egui/src/instances_shared_props_tests.rs @@ -0,0 +1,77 @@ +use egui::accesskit::{Node, Role}; +use figcraft_doc::{NodeId, NodeKind}; +use figcraft_engine::Session; +use serde_json::json; + +use crate::component_swap_default_tests::{centre, click, tree}; +use crate::layers_drag_tests::Ui; + +fn id(v: serde_json::Value) -> NodeId { + NodeId(v["id"].as_u64().unwrap()) +} + +fn combos(nodes: &[Node]) -> Vec { + nodes.iter().filter(|n| n.role() == Role::ComboBox).filter_map(|n| n.value().map(str::to_string)).collect() +} + +fn small_and_large_instances_selected(with_a_rectangle: bool) -> (Ui, Vec<(String, NodeId)>, Vec) { + let mut s = Session::new(); + let mut variants = Vec::new(); + for (k, name) in ["Size=S, State=Default", "Size=L, State=Default", "Size=S, State=Hover", "Size=L, State=Hover"].iter().enumerate() { + let f = id(s.execute("frame.create", &json!({"x": 0, "y": 20 + k * 44, "width": 80, "height": 30, "name": name})).unwrap()); + variants.push((name.to_string(), id(s.execute("component.create", &json!({"ids": [f]})).unwrap()))); + } + s.execute("component.combineVariants", &json!({"ids": variants.iter().map(|v| v.1).collect::>()})).unwrap(); + let small = id(s.execute("instance.create", &json!({"component": variants[0].1, "x": 300, "y": 20})).unwrap()); + let large = id(s.execute("instance.create", &json!({"component": variants[1].1, "x": 300, "y": 80})).unwrap()); + let mut selected = vec![small, large]; + if with_a_rectangle { + selected.push(id(s.execute("shape.rectangle", &json!({"x": 500, "y": 20, "width": 20, "height": 20})).unwrap())); + } + s.execute("select.set", &json!({"ids": selected})).unwrap(); + let u = Ui::new(s); + u.ctx.enable_accesskit(); + (u, variants, vec![small, large]) +} + +fn main_of(u: &Ui, instance: NodeId) -> NodeId { + match &u.app.session.doc().unwrap().node(instance).unwrap().kind { + NodeKind::Instance { component, .. } => *component, + _ => panic!("not an instance"), + } +} + +fn pick(u: &mut Ui, shown: &str, value: &str) { + let nodes = tree(u); + let dropdown = nodes.iter().find(|n| n.role() == Role::ComboBox && n.value() == Some(shown)).unwrap_or_else(|| panic!("a {shown} dropdown")); + click(u, centre(dropdown)); + let nodes = tree(u); + let item = nodes + .iter() + .find(|n| n.label() == Some(value) && !matches!(n.role(), Role::ComboBox | Role::TextInput) && n.bounds().is_some()) + .unwrap_or_else(|| panic!("{value} in the menu")); + click(u, centre(item)); +} + +#[test] +fn two_selected_instances_show_their_shared_variant_properties_and_set_them_together() { + let (mut u, variants, instances) = small_and_large_instances_selected(false); + let variant = |name: &str| variants.iter().find(|v| v.0 == name).unwrap().1; + + let shown = combos(&tree(&mut u)); + assert!(shown.contains(&"Mixed".to_string()), "Size differs between them: {shown:?}"); + assert!(shown.contains(&"Default".to_string()), "State is the same: {shown:?}"); + + pick(&mut u, "Mixed", "L"); + assert_eq!(instances.iter().map(|i| main_of(&u, *i)).collect::>(), [variant("Size=L, State=Default"); 2]); + + pick(&mut u, "Default", "Hover"); + assert_eq!(instances.iter().map(|i| main_of(&u, *i)).collect::>(), [variant("Size=L, State=Hover"); 2]); +} + +#[test] +fn instances_selected_with_a_plain_layer_show_no_instance_properties() { + let (mut u, _, _) = small_and_large_instances_selected(true); + let shown = combos(&tree(&mut u)); + assert!(!shown.iter().any(|v| v == "Mixed" || v == "Default"), "no property rows: {shown:?}"); +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 32d859f6c..48cb7902e 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -150,6 +150,8 @@ mod import_report_tests; #[cfg(test)] mod inspect_fields_tests; #[cfg(test)] +mod instances_shared_props_tests; +#[cfg(test)] mod layers_behaviour_tests; #[cfg(test)] mod layers_component_rows_tests; diff --git a/crates/ui-egui/src/panels/component_panel.rs b/crates/ui-egui/src/panels/component_panel.rs index 08f5c543d..ed6398d73 100644 --- a/crates/ui-egui/src/panels/component_panel.rs +++ b/crates/ui-egui/src/panels/component_panel.rs @@ -31,6 +31,7 @@ use crate::widgets; pub fn instance_section(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId]) { let [id] = sel else { combine_ui(app, ui, doc, sel); + instances_ui(app, ui, doc, sel); return; }; let Some(n) = doc.node(*id) else { return }; @@ -712,7 +713,7 @@ fn instance_ui(app: &mut FigApp, ui: &mut Ui, doc: &Document, n: &Node) { } }); } - instance_props(app, ui, doc, n, &comps); + instance_props(app, ui, doc, &[n.id], &comps); // Exposed nested instances: their properties, under their names. if !nested { for c in figcraft_engine::components::exposed_copies(doc, id) { @@ -722,7 +723,7 @@ fn instance_ui(app: &mut FigApp, ui: &mut Ui, doc: &Document, n: &Node) { icons::paint(ui.painter(), r, Icon::Instance, crate::theme::COMPONENT); ui.label(egui::RichText::new(&cn.name).font(semibold(11.0)).color(t.text)); }); - instance_props(app, ui, doc, cn, &comps); + instance_props(app, ui, doc, &[cn.id], &comps); } } } @@ -732,38 +733,120 @@ fn nested_in_main(doc: &Document, id: NodeId) -> bool { !inside_instance(doc, id) && figcraft_engine::components::owning_component(doc, id).is_some_and(|c| c != id) } -/// Variant and component property controls for instance `n`. -fn instance_props(app: &mut FigApp, ui: &mut Ui, doc: &Document, n: &Node, comps: &[(NodeId, String)]) { - let NodeKind::Instance { component, props } = &n.kind else { return }; - let id = n.id; - let set = variant_set(doc, *component); - let slots = slots_of(doc, id); +/// The Instance section for a selection of two or more instances: the properties they share. A +/// selection with any other layer shows nothing. +fn instances_ui(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId]) { + if sel.len() < 2 || !sel.iter().all(|id| matches!(doc.node(*id).map(|n| &n.kind), Some(NodeKind::Instance { .. }))) { + return; + } + let t = Tokens::get(ui.ctx()); + let comps = local_components(app, ui, doc); + widgets::separator(ui); + row(ui, 36.0, |ui| { + ui.label(egui::RichText::new(tr("Instance")).font(semibold(11.0)).color(t.text)); + }); + instance_props(app, ui, doc, sel, &comps); +} + +/// A variant property the selected instances share: the values every one of their sets has, and +/// the current value, None when it differs between them (Mixed). +struct SharedVariantProp { + name: String, + values: Vec, + current: Option, +} + +/// A boolean, text, instance-swap or slot property the selected instances share, by name and type: +/// its definition (the first instance's) and the value, None when it differs between them (Mixed). +struct SharedProp { + name: String, + def: PropDef, + value: Option, +} + +/// The variant and other properties of instance `id` with its own values (a property it doesn't +/// set has its default). None when `id` isn't an instance. +fn own_props(doc: &Document, id: NodeId) -> Option<(Vec, Vec)> { + let Some(NodeKind::Instance { component, props }) = doc.node(id).map(|n| &n.kind) else { return None }; + let current = doc.node(*component).map(|c| variant_props(&c.name)).unwrap_or_default(); + let variants = variant_set(doc, *component) + .map(|set| variant_options(doc, set)) + .unwrap_or_default() + .into_iter() + .map(|(name, values)| SharedVariantProp { current: Some(current.get(&name).cloned().unwrap_or_default()), name, values }) + .collect(); + let others = instance_prop_list(doc, *component) + .into_iter() + .map(|(name, def)| { + let value = props.get(&name).cloned().unwrap_or_else(|| figcraft_engine::components::prop_default_value(&def)); + SharedProp { name, def, value: Some(value) } + }) + .collect(); + Some((variants, others)) +} + +/// The properties every instance in `ids` has, in the first one's order, with the values they share; +/// nothing when any of `ids` isn't an instance. +fn shared_props(doc: &Document, ids: &[NodeId]) -> (Vec, Vec) { + let Some((first, rest)) = ids.split_first() else { return Default::default() }; + let Some((mut variants, mut others)) = own_props(doc, *first) else { return Default::default() }; + for id in rest { + let Some((own_variants, own_others)) = own_props(doc, *id) else { return Default::default() }; + variants.retain_mut(|shared| { + let Some(own) = own_variants.iter().find(|o| o.name == shared.name) else { return false }; + shared.values.retain(|v| own.values.contains(v)); + if shared.current != own.current { + shared.current = None; + } + true + }); + others.retain_mut(|shared| { + let Some(own) = + own_others.iter().find(|o| o.name == shared.name && std::mem::discriminant(&o.def) == std::mem::discriminant(&shared.def)) + else { + return false; + }; + if shared.value != own.value { + shared.value = None; + } + true + }); + } + (variants, others) +} + +/// Variant and component property controls for instances `ids`: the properties they share, set on +/// all of them at once. Slots show only for a single instance. +fn instance_props(app: &mut FigApp, ui: &mut Ui, doc: &Document, ids: &[NodeId], comps: &[(NodeId, String)]) { + let (variants, others) = shared_props(doc, ids); + let slots = match ids { + [id] => slots_of(doc, *id), + _ => Vec::new(), + }; // Variant properties. - if let Some(set) = set { - let current = doc.node(*component).map(|c| variant_props(&c.name)).unwrap_or_default(); - for (k, vals) in variant_options(doc, set) { - let cur = current.get(&k).cloned().unwrap_or_default(); - row(ui, 32.0, |ui| { - prop_label(ui, &k, Icon::ComponentSet); - let w = ui.available_width().max(60.0); - // A string variable naming one of the values can choose it. - crate::variable_ui::bindable(app, ui, &[id], &format!("{PROP_BINDING}{k}"), VariableType::String, w, |app, ui| { - let resp = widgets::dropdown(ui, &cur, w, None); - menu_popup(&resp).show(|ui| { - for v in &vals { - if menu_item(ui, v, "") { - app.run("instance.setProperties", json!({"ids": [id], "properties": {k.clone(): v}})); - ui.close(); - } + for SharedVariantProp { name: k, values: vals, current } in variants { + row(ui, 32.0, |ui| { + prop_label(ui, &k, Icon::ComponentSet); + let w = ui.available_width().max(60.0); + // A string variable naming one of the values can choose it. + crate::variable_ui::bindable(app, ui, ids, &format!("{PROP_BINDING}{k}"), VariableType::String, w, |app, ui| { + let resp = widgets::dropdown(ui, current.as_deref().unwrap_or(tr("Mixed")), w, None); + menu_popup(&resp).show(|ui| { + for v in &vals { + if menu_item(ui, v, "") { + app.run("instance.setProperties", json!({"ids": ids, "properties": {k.clone(): v}})); + ui.close(); } - }); + } }); }); - } + }); } // Boolean, text and instance-swap properties. - for (k, d) in instance_prop_list(doc, *component) { - let v = props.get(&k).cloned().unwrap_or_else(|| figcraft_engine::components::prop_default_value(&d)); + for SharedProp { name: k, def: d, value } in others { + if matches!(d, PropDef::Slot { .. }) && !slots.iter().any(|(_, name)| *name == k) { + continue; + } row(ui, 32.0, |ui| { prop_label(ui, &k, type_icon(&d)); let w = ui.available_width().max(60.0); @@ -771,26 +854,28 @@ fn instance_props(app: &mut FigApp, ui: &mut Ui, doc: &Document, n: &Node, comps let bind_field = format!("{PROP_BINDING}{k}"); match d { PropDef::Boolean { .. } => { - crate::variable_ui::bindable(app, ui, &[id], &bind_field, VariableType::Boolean, w, |app, ui| { - let on = v.as_bool().unwrap_or(false); - if widgets::checkbox(ui, on, "") { - app.run("instance.setProperties", json!({"ids": [id], "properties": {k.clone(): !on}})); + crate::variable_ui::bindable(app, ui, ids, &bind_field, VariableType::Boolean, w, |app, ui| { + let state = value.as_ref().map(|v| v.as_bool().unwrap_or(false)); + if widgets::checkbox_tri(ui, state, "") { + app.run("instance.setProperties", json!({"ids": ids, "properties": {k.clone(): !state.unwrap_or(false)}})); } }); } PropDef::Text { .. } => { - crate::variable_ui::bindable(app, ui, &[id], &bind_field, VariableType::String, w, |app, ui| { - let cur = v.as_str().unwrap_or_default().to_string(); - if let Some(ns) = widgets::text_field(ui, Id::unique(("iprop", id, k.as_str())), &cur, w, "") + crate::variable_ui::bindable(app, ui, ids, &bind_field, VariableType::String, w, |app, ui| { + let cur = value.as_ref().and_then(Value::as_str).unwrap_or_default().to_string(); + let placeholder = if value.is_some() { "" } else { tr("Mixed") }; + if let Some(ns) = widgets::text_field(ui, Id::unique(("iprop", ids, k.as_str())), &cur, w, placeholder) && ns != cur { - app.run("instance.setProperties", json!({"ids": [id], "properties": {k.clone(): ns}})); + app.run("instance.setProperties", json!({"ids": ids, "properties": {k.clone(): ns}})); } }); } PropDef::InstanceSwap { preferred, .. } => { - if let Some(c) = swap_dropdown(ui, doc, figcraft_engine::params::id_of(&v), &preferred, comps, w, &k).1 { - app.run("instance.setProperties", json!({"ids": [id], "properties": {k.clone(): c.0}})); + let cur = value.as_ref().and_then(figcraft_engine::params::id_of); + if let Some(c) = swap_dropdown(ui, doc, cur, value.is_none(), &preferred, comps, w, &k).1 { + app.run("instance.setProperties", json!({"ids": ids, "properties": {k.clone(): c.0}})); } } PropDef::Variant { .. } => {} @@ -806,18 +891,24 @@ fn instance_props(app: &mut FigApp, ui: &mut Ui, doc: &Document, n: &Node, comps /// The dropdown of an instance-swap property showing component `cur`: its menu lists the /// property's preferred components first (when it has any), then every component in the file. The -/// dropdown, and the component picked (picking the current one picks nothing). `name` labels it for -/// assistive technology. +/// dropdown, and the component picked (picking the current one picks nothing). Without `cur` it reads +/// "Mixed" when `mixed` (the selected instances swap in different components), else "None". `name` +/// labels it for assistive technology. pub(crate) fn swap_dropdown( ui: &mut Ui, doc: &Document, cur: Option, + mixed: bool, preferred: &[NodeId], comps: &[(NodeId, String)], w: f32, name: &str, ) -> (egui::Response, Option) { - let label = cur.and_then(|c| doc.node(c)).map(|c| c.name.clone()).unwrap_or_else(|| tr("None").into()); + let label = match cur.and_then(|c| doc.node(c)) { + Some(c) => c.name.clone(), + None if mixed => tr("Mixed").into(), + None => tr("None").into(), + }; let resp = widgets::dropdown(ui, &label, w, Some(Icon::Instance)); if !name.is_empty() { crate::a11y::combo(&resp, name, &label, crate::a11y::menu_open(&resp)); diff --git a/crates/ui-egui/src/panels/dev_mode.rs b/crates/ui-egui/src/panels/dev_mode.rs index 09c3b9732..f80c4789f 100644 --- a/crates/ui-egui/src/panels/dev_mode.rs +++ b/crates/ui-egui/src/panels/dev_mode.rs @@ -404,7 +404,8 @@ pub fn playground_section(app: &mut FigApp, ui: &mut Ui, doc: &Document, id: Nod widgets::label(ui, name, t.text_secondary); let preferred: Vec = p["preferred"].as_array().into_iter().flatten().filter_map(figcraft_engine::params::id_of).collect(); let w = ui.available_width().max(60.0); - if let Some(c) = crate::component_panel::swap_dropdown(ui, doc, figcraft_engine::params::id_of(value), &preferred, &comps, w, name).1 + if let Some(c) = + crate::component_panel::swap_dropdown(ui, doc, figcraft_engine::params::id_of(value), false, &preferred, &comps, w, name).1 { set = Some((name.to_string(), json!(c.0))); } diff --git a/docs/components-parity.md b/docs/components-parity.md index fa4d2494e..5ca79aed4 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (with several instances selected, the Design panel shows the properties they share, Mixed where their values differ, and sets a value on all of them; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -12,6 +12,7 @@ accounts). | Feature | Status | Notes | |---|---|---| +| 2026-11-18 | patch | M3: with two or more instances selected the Design panel showed no instance properties, so changing a variant or a property meant selecting each instance in turn. It now shows the variant, boolean, text and instance-swap properties they share (by name and type; a variant property lists the values every one of their sets has), each reading Mixed where their values differ, and a value chosen there is set on every selected instance in one step, as Figma does. A selection with any layer that isn't an instance shows none. Tests: `instances_shared_props_tests` | | 2026-11-11 | minor | M3, #2022: an instance lists only the properties its variant's layers use (its variant properties, slots, and the boolean, text and instance swap properties a layer of its current variant reads), as measured in Figma's web app: an instance of variant A lists `State` and `A label`, never `B label` or a property no layer reads. The set and its variants still list every definition, so unused ones can be deleted there. A long property name in the panel is cut to one line with an ellipsis, the full name on hover, instead of wrapping over the rows around it. Tests: `prop_order_tests::an_instance_lists_only_the_properties_its_variant_uses`, `component_props_reorder_tests::a_long_property_name_stays_on_one_line`, `prop_value_tests::a_set_keeps_each_named_text_definition_and_layers_read_their_own`. Grade unchanged. | | Create component, instances, detach, reset, go to main, restore main, push changes | done | push from a nested layer goes to the outer main; with two or more layers selected the Design panel header's component button opens a menu with Create component, Create multiple components (each layer its own component in place, one undo step) and Create component set (each layer a component, wrapped in place in a set 20 px around: variants `Property 1=` left to right, `prop=value` names kept, layers that all share a name give a set of that name with `Property 1=Default` variants; measured in Figma), one layer keeps the plain click (#2088) | | Per-layer overrides with reset; kept across main edits, nested swaps, copy/paste | done | main edits match a full rebuild exactly at 2,000 instances | From 0f54b38f4218512d55b1fb0983500b4d6bff347a Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:51:49 -0500 Subject: [PATCH 09/36] M3: A variable created with a group shown goes into that group With a group selected in the Local variables window, + Create variable named the new variable after its type alone ("Number"), so it went to the collection's top level. The table, showing the group, didn't show it; only All variables did. In Figma it's made in the group shown. Duplicate already kept the group (the copy is "space/sm copy"). The new variable's name now starts with the group shown. Its name opens for editing right away, and the row's field edited the whole name while the row shows only the last part, so typing a name over the new grouped variable would have moved it straight back out of the group. The field now edits the part shown and keeps the group; the Edit variable window still edits the whole name, which is where a variable moves between groups by typing. A name typed there with nothing but slashes and spaces is ignored, as an empty one is: under the group it would clean up to the group's own name and drop the variable out of it. Creating a collection clears the group shown, as picking another collection does, so its first variable isn't named after a group of the collection shown before. --- crates/ui-egui/src/dialogs/variables_panel.rs | 11 +- crates/ui-egui/src/lib.rs | 2 + .../src/variables_group_create_tests.rs | 127 ++++++++++++++++++ docs/components-parity.md | 5 +- 4 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 crates/ui-egui/src/variables_group_create_tests.rs diff --git a/crates/ui-egui/src/dialogs/variables_panel.rs b/crates/ui-egui/src/dialogs/variables_panel.rs index 961471cd0..55bb0cdc2 100644 --- a/crates/ui-egui/src/dialogs/variables_panel.rs +++ b/crates/ui-egui/src/dialogs/variables_panel.rs @@ -683,6 +683,7 @@ fn create_collection(app: &mut FigApp, vars: &Variables, st: &mut Editor) { { st.library = None; st.collection = Some(id.clone()); + st.group = None; start_rename(st, Rename::Collection(id)); } } @@ -896,7 +897,11 @@ fn var_row(app: &mut FigApp, ui: &mut Ui, view: &View, coll: &Collection, v: &Va // An inherited variable is named (and deleted) in the collection it extends. let inherited = v.extends.is_some(); if editable && st.rename.as_ref() == Some(&target) { - if let Some(name) = rename_field(ui, st, &target, &v.name, name_r, regular(11.0)) { + // The row shows the name's last part: the field edits that and keeps the group. A name of + // slashes and spaces alone is ignored, as the group would swallow it and drop the variable. + let (group, short) = v.name.rsplit_once('/').unwrap_or(("", &v.name)); + if let Some(typed) = rename_field(ui, st, &target, short, name_r, regular(11.0)).filter(|n| n.split('/').any(|p| !p.trim().is_empty())) { + let name = if group.is_empty() { typed } else { format!("{group}/{typed}") }; app.run("variable.update", json!({"variable": v.id, "name": name})); } } else { @@ -1160,7 +1165,9 @@ fn create_row(app: &mut FigApp, ui: &mut Ui, view: &View, coll: &Collection, st: VariableType::Boolean => tr_noop("Boolean"), }; if menu_item(ui, tr(label), "") { - let name = unique(label, |n| view.in_collection(&coll.id).any(|v| v.name == n)); + // Made in the group shown, so the table showing it lists it. + let base = st.group.as_ref().map_or_else(|| label.to_string(), |g| format!("{g}/{label}")); + let name = unique(&base, |n| view.in_collection(&coll.id).any(|v| v.name == n)); let params = json!({"collection": coll.id, "name": name, "type": kind.id()}); if let Some(id) = app.run("variable.create", params).and_then(|r| r["id"].as_str().map(str::to_string)) { st.query.clear(); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 32d859f6c..d3b4ad05b 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -300,6 +300,8 @@ mod variable_picker_tests; #[cfg(test)] mod variables_export_ui_tests; #[cfg(test)] +mod variables_group_create_tests; +#[cfg(test)] mod variables_rename_tests; #[cfg(test)] mod variables_select_tests; diff --git a/crates/ui-egui/src/variables_group_create_tests.rs b/crates/ui-egui/src/variables_group_create_tests.rs new file mode 100644 index 000000000..81ed67ef7 --- /dev/null +++ b/crates/ui-egui/src/variables_group_create_tests.rs @@ -0,0 +1,127 @@ +//! Variables made and named with a group shown in the Local variables window: Create variable +//! and Duplicate put the variable in that group, and renaming it in its row edits the part shown. +use egui::{Event, Key, Modifiers, PointerButton, Pos2}; +use figcraft_engine::Session; +use serde_json::json; + +use crate::layers_drag_tests::Ui; +use crate::live_tests::{flat, has_text, text_center, texts}; + +fn window_with_groups() -> Ui { + let mut s = Session::new(); + s.execute("variable.createCollection", &json!({"name": "Theme"})).unwrap(); + for n in ["space/sm", "color/brand"] { + s.execute("variable.create", &json!({"collection": "Theme", "name": n, "type": "number", "value": 1})).unwrap(); + } + let mut u = Ui::new(s); + u.app.ui.variables = Some(Default::default()); + settle(&mut u); + u +} + +fn settle(u: &mut Ui) { + for _ in 0..8 { + u.frame(vec![]); + } +} + +fn click(u: &mut Ui, p: Pos2, button: PointerButton) { + for pressed in [true, false] { + u.frame(vec![Event::PointerMoved(p), Event::PointerButton { pos: p, button, pressed, modifiers: Modifiers::NONE }]); + } + settle(u); +} + +fn leftmost(u: &mut Ui, s: &str) -> Pos2 { + let shapes = flat(&u.frame_output(vec![]).shapes); + let (_, at, size) = + texts(&shapes).into_iter().filter(|(t, ..)| t == s).min_by(|a, b| a.1.x.total_cmp(&b.1.x)).unwrap_or_else(|| panic!("{s} drawn")); + at + size / 2.0 +} + +fn names(u: &Ui) -> Vec { + let mut v: Vec = u.app.session.doc().unwrap().variables.variables.iter().map(|v| v.name.clone()).collect(); + v.sort(); + v +} + +fn shown(u: &mut Ui, s: &str) -> bool { + has_text(&flat(&u.frame_output(vec![]).shapes), s) +} + +#[test] +fn a_variable_created_with_a_group_shown_goes_into_that_group_and_keeps_it_when_named() { + let mut u = window_with_groups(); + let group = leftmost(&mut u, "space"); + click(&mut u, group, PointerButton::Primary); + assert!(!shown(&mut u, "brand"), "only the space group is shown"); + + let create = text_center(&flat(&u.frame_output(vec![]).shapes), "+ Create variable"); + click(&mut u, create, PointerButton::Primary); + let number = text_center(&flat(&u.frame_output(vec![]).shapes), "Number"); + click(&mut u, number, PointerButton::Primary); + assert_eq!(names(&u), ["color/brand", "space/Number", "space/sm"]); + + u.frame(vec![Event::Text("lg".into())]); + for pressed in [true, false] { + u.frame(vec![Event::Key { key: Key::Enter, physical_key: None, pressed, repeat: false, modifiers: Modifiers::NONE }]); + } + settle(&mut u); + assert_eq!(names(&u), ["color/brand", "space/lg", "space/sm"], "naming it in its row keeps the group"); + assert!(shown(&mut u, "lg"), "and it is in the table shown"); + assert!(u.app.ui.last_error.is_none(), "{:?}", u.app.ui.last_error); +} + +#[test] +fn a_variable_duplicated_in_a_group_stays_in_it_and_in_view() { + let mut u = window_with_groups(); + let group = leftmost(&mut u, "space"); + click(&mut u, group, PointerButton::Primary); + let row = leftmost(&mut u, "sm"); + click(&mut u, row, PointerButton::Secondary); + let duplicate = text_center(&flat(&u.frame_output(vec![]).shapes), "Duplicate"); + click(&mut u, duplicate, PointerButton::Primary); + assert_eq!(names(&u), ["color/brand", "space/sm", "space/sm copy"]); + assert!(shown(&mut u, "sm copy")); +} + +fn create_number(u: &mut Ui) { + let create = text_center(&flat(&u.frame_output(vec![]).shapes), "+ Create variable"); + click(u, create, PointerButton::Primary); + let number = text_center(&flat(&u.frame_output(vec![]).shapes), "Number"); + click(u, number, PointerButton::Primary); +} + +fn type_and_enter(u: &mut Ui, typed: &str) { + u.frame(vec![Event::Text(typed.into())]); + for pressed in [true, false] { + u.frame(vec![Event::Key { key: Key::Enter, physical_key: None, pressed, repeat: false, modifiers: Modifiers::NONE }]); + } + settle(u); +} + +#[test] +fn a_name_of_slashes_alone_leaves_the_variable_in_its_group() { + for typed in ["/", " / / "] { + let mut u = window_with_groups(); + let group = leftmost(&mut u, "space"); + click(&mut u, group, PointerButton::Primary); + create_number(&mut u); + type_and_enter(&mut u, typed); + assert_eq!(names(&u), ["color/brand", "space/Number", "space/sm"], "{typed:?}"); + } +} + +#[test] +fn a_new_collection_takes_its_first_variable_outside_the_group_shown_before() { + let mut u = window_with_groups(); + let group = leftmost(&mut u, "space"); + click(&mut u, group, PointerButton::Primary); + let heading = leftmost(&mut u, "Collections"); + let (_, at, _) = texts(&flat(&u.frame_output(vec![]).shapes)).into_iter().find(|(t, ..)| t == "Collections").unwrap(); + click(&mut u, Pos2::new(at.x - 16.0 + 200.0 - 20.0, heading.y), PointerButton::Primary); + assert_eq!(u.app.session.doc().unwrap().variables.collections.len(), 2, "the + by Collections made one"); + type_and_enter(&mut u, "Sizes"); + create_number(&mut u); + assert_eq!(names(&u), ["Number", "color/brand", "space/sm"]); +} diff --git a/docs/components-parity.md b/docs/components-parity.md index fa4d2494e..48a9486c1 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (with a variable group shown in the Local variables window, Create variable makes the variable in that group, and renaming a variable in its row changes the part shown and keeps its group; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -65,7 +65,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Editing a style updates its layers; detach and delete keep values; editing a styled property unlinks that style | done | an edited fill/stroke/effect/grid list or text chars unlink; applying a style replaces variables bound to what it sets; text styles on text layers only | | Organising styles: folders by `/` names, order, duplicate, rename folder, Local styles list | done | `style.move` (into a folder renames), `style.duplicate` (right below), `style.renameFolder`; the page's Local styles list by type and folder (drag to reorder, right-click) | | Variables inside styles (paint, effect, grid and text styles; each user resolves them in its own modes) | done | `style.bind`, `style_vars_tests`; the editor binds paint colours, shadow colours, blur radii, grid sizes and a text style's font, font style (a face name from a string variable, or a numeric weight from a number variable, which picks the nearest face and a variable font's `wght` axis), size, line height and letter spacing, the rest through the command; a bound line height is applied in pixels, as the reference tool does (measured 2026-11-10) | -| Variables: colour, number, string, boolean; collections, modes, aliases, scopes, groups | done | behaviour suite: `variables_behaviour_tests.rs`; aliases same type, no loops (also on create); colour calculations per mode (`{alpha}`: a colour variable with its alpha replaced, `{mix}`: a per-channel blend of two colour variables or literals; they compose, can't loop, and bound layers, modes and undo follow them; REST, CSS, Penpot and `.fig` exports write the colour they show in each of their collection's modes, other collections in their default modes; read-only in the panel, which can swap one for an alias or detach it; `variables_colour_tests.rs`), beyond the incumbent, whose variables only alias; scopes filter pickers only; several variables can be selected in the editor (Shift and Cmd/Ctrl click) and deleted, moved to a group or rescoped at once; a group can be duplicated from its row's menu (Duplicate group, one undo step); the window resizes from its edges and corners (minimum 600 x 240) and keeps its size and place while the app runs, #2354 | +| Variables: colour, number, string, boolean; collections, modes, aliases, scopes, groups | done | behaviour suite: `variables_behaviour_tests.rs`; aliases same type, no loops (also on create); colour calculations per mode (`{alpha}`: a colour variable with its alpha replaced, `{mix}`: a per-channel blend of two colour variables or literals; they compose, can't loop, and bound layers, modes and undo follow them; REST, CSS, Penpot and `.fig` exports write the colour they show in each of their collection's modes, other collections in their default modes; read-only in the panel, which can swap one for an alias or detach it; `variables_colour_tests.rs`), beyond the incumbent, whose variables only alias; scopes filter pickers only; several variables can be selected in the editor (Shift and Cmd/Ctrl click) and deleted, moved to a group or rescoped at once; a group can be duplicated from its row's menu (Duplicate group, one undo step); Create variable makes the variable in the group shown, and a row's rename edits the name's last part; the window resizes from its edges and corners (minimum 600 x 240) and keeps its size and place while the app runs, #2354 | | Modes: add, duplicate, rename, delete, set as default / reorder | done | layers on Auto follow a new default; explicit modes stay | | Deleting a bound variable or its collection | done | layers keep their last value and are unbound; aliases to it take its values and colour calculations reading it keep the colour they show | | Code syntax per platform (Web, iOS, Android) | done | generated CSS uses the Web name, SwiftUI the iOS one and Compose the Android one (a variable without one keeps its value there); in the variables JSON; ArkUI and Flutter have no platform of their own and write values | @@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Date | Change | Summary | |---|---|---| +| 2026-11-19 | patch | M3: with a group selected in the Local variables window, + Create variable named the new variable without the group, so it went to the collection's top level and the table, showing the group, didn't show it; only All variables did. It's now made in the group shown (`space/Number`), as in Figma, where duplicating already kept the group. Renaming a variable in its row edited its whole name while the row shows the last part, so typing a name over a new grouped variable moved it out of the group; the field now edits the part shown and keeps the group (the Edit variable window still edits the whole name), and ignores a name of slashes alone. Creating a collection clears the group shown. Tests: `variables_group_create_tests` | | 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`::S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. | | 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. | | 2026-11-18 | minor | M3, gap 10: library analytics count insertions and detachments of styles and variables. Applying one, or copying or duplicating content that uses it, inserts it; the Detach button detaches it; an instance counts as its component alone. Show usage and `library.usage` give them per style and variable over the chosen period. Modes aren't counted. Numbers unchanged. Tests: `library_asset_counts_tests`, `library_assets_tests`. | From b0569e27236cec024cd34a40f1dcc2f1c76f560d Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:16:19 -0500 Subject: [PATCH 10/36] M3: Layers: the eye and padlock stay in view, and a name takes at most 400 pt A text layer named after a paragraph made the list over 1000 pt wide (#1904 widens it to the widest name). The eye and padlock sat at the row's far end, so hiding a layer meant scrolling sideways to find them. The eye and padlock now sit at the right edge of the list's view. While they show (hover, a hidden or locked layer, or a row a held sweep has taken in), the name is clipped before them instead of drawn beneath. Scrolling sideways still reveals the rest of a long name, as #1904 asked. On a row as wide as the view nothing moves: the row is already inset 8 pt from the view's edge, so the eye stays at 262 to 282 pt (mirrored 1158 to 1178 pt), as on main. On a row nested so deep that the buttons at the view's edge would cover its disclosure triangle, icon or name start, they stay after the name start, at the row's end, so the triangle still takes clicks. NAME_ROOM drops from 1200 to 400 pt. It stops a name of thousands of characters (#1650) from making the list that wide, and 400 pt still holds a variant name like "Size=small, Type=primary, State=default, Icon=leading, Width=full" in full. The "W" name in the measuring test is 25 letters, and the test checks that it is wider than the panel leaves a name and well under the cap, so it holds with and without craft-fonts. Tests: the_eye_of_a_long_named_layer_sits_at_the_panels_edge_and_is_clickable, a_paragraph_named_text_layer_widens_the_list_no_more_than_the_name_cap, the_eye_of_an_ordinary_row_stays_where_it_was (passes on main too), a_swept_long_named_row_keeps_its_name_clipped_before_the_eye and the_disclosure_triangle_of_a_deeply_nested_row_is_not_under_the_padlock. --- crates/ui-egui/src/layers_wide_names_tests.rs | 150 +++++++++++++++++- crates/ui-egui/src/panels/layers.rs | 76 ++++++--- docs/ui-parity.md | 5 +- 3 files changed, 207 insertions(+), 24 deletions(-) diff --git a/crates/ui-egui/src/layers_wide_names_tests.rs b/crates/ui-egui/src/layers_wide_names_tests.rs index cccd80bec..aea107756 100644 --- a/crates/ui-egui/src/layers_wide_names_tests.rs +++ b/crates/ui-egui/src/layers_wide_names_tests.rs @@ -122,10 +122,13 @@ fn a_wide_name_among_many_long_narrow_ones_is_still_measured() { for _ in 0..50 { named(&mut s, &"i".repeat(100), None); } - named(&mut s, &"W".repeat(70), None); + named(&mut s, &"W".repeat(25), None); let mut u = Ui::new(s); - let (elided, ..) = painted(&mut u, "WWWW"); + let (elided, _, size) = painted(&mut u, "WWWW"); assert!(!elided, "the wide name reads in full"); + // Wider than the panel leaves a name, so it reads in full only if it was measured, and well + // under the cap, with or without craft-fonts. + assert!(size.x > 200.0 && size.x < crate::layers::NAME_ROOM - 100.0, "the test's name is {} pt wide", size.x); } /// Review: a name is laid out as it is painted, on one line, so line breaks in it don't make it @@ -159,3 +162,146 @@ fn a_drag_released_over_the_canvas_drops_nowhere() { } assert_eq!(u.app.session.doc().unwrap().node(page).unwrap().children, order, "no reorder"); } + +fn hidden_layer_eye(name: &str, mirrored: bool) -> (Ui, NodeId, egui::Rect) { + let mut s = Session::new(); + let layer = + id(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20, "props": {"name": name, "visible": false}})).unwrap()); + let mut u = Ui::new(s); + u.app.ui.mirrored = mirrored; + u.ctx.enable_accesskit(); + for _ in 0..3 { + u.frame(vec![]); + } + let out = u.frame_output(vec![]); + let nodes = out.platform_output.accesskit_update.expect("an AccessKit update").nodes; + let eye = nodes + .iter() + .find(|(_, n)| n.role() == egui::accesskit::Role::Button && n.label() == Some("Hidden")) + .and_then(|(_, n)| n.bounds()) + .expect("the eye of the hidden layer"); + (u, layer, egui::Rect::from_min_max(Pos2::new(eye.x0 as f32, eye.y0 as f32), Pos2::new(eye.x1 as f32, eye.y1 as f32))) +} + +#[test] +fn the_eye_of_a_long_named_layer_sits_at_the_panels_edge_and_is_clickable() { + for mirrored in [false, true] { + let (_, _, short) = hidden_layer_eye("Short", mirrored); + let (mut u, layer, long) = hidden_layer_eye(LONG, mirrored); + let (a, b) = if mirrored { (long.min.x, short.min.x) } else { (long.max.x, short.max.x) }; + assert!((a - b).abs() < 1.0, "mirrored {mirrored}: the eye at the panel's edge, not past it: {a} vs {b}"); + u.button(long.center(), true); + u.button(long.center(), false); + assert!(u.app.session.doc().unwrap().node(layer).unwrap().visible, "mirrored {mirrored}: the eye shows the layer"); + } +} + +#[test] +fn a_paragraph_named_text_layer_widens_the_list_no_more_than_the_name_cap() { + let mut s = Session::new(); + named(&mut s, &"After the Chicago World's Fair, Tiffany built Laurelton Hall on Long Island. ".repeat(4), None); + let mut u = Ui::new(s); + let (elided, p, size) = painted(&mut u, "After the Chicago"); + assert!(elided, "a paragraph elides at the cap"); + assert!(p.x + size.x <= p.x + 400.0 + 1.0, "the name takes at most 400 pt: {}", size.x); +} + +/// The bounds of the buttons named `label` (AccessKit), from left to right. +fn buttons(u: &mut Ui, label: &str) -> Vec { + let out = u.frame_output(vec![]); + let nodes = out.platform_output.accesskit_update.expect("an AccessKit update").nodes; + let mut rects: Vec = nodes + .iter() + .filter(|(_, n)| n.role() == egui::accesskit::Role::Button && n.label() == Some(label)) + .filter_map(|(_, n)| n.bounds()) + .map(|b| egui::Rect::from_min_max(Pos2::new(b.x0 as f32, b.y0 as f32), Pos2::new(b.x1 as f32, b.y1 as f32))) + .collect(); + rects.sort_by(|a, b| a.min.x.total_cmp(&b.min.x)); + rects +} + +/// Review: an ordinary row as wide as the view keeps its eye where it was before the eye and padlock +/// were held in view (measured on `main`: 262 to 282 pt, mirrored 1158 to 1178 pt), with a vertical +/// scrollbar or without. +#[test] +fn the_eye_of_an_ordinary_row_stays_where_it_was() { + for count in [1, 60] { + for mirrored in [false, true] { + let mut s = Session::new(); + for i in 0..count { + let props = json!({"name": format!("Rect {i}"), "visible": i + 1 != count}); + s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20, "props": props})).unwrap(); + } + let mut u = Ui::new(s); + u.app.ui.mirrored = mirrored; + u.ctx.enable_accesskit(); + for _ in 0..3 { + u.frame(vec![]); + } + let eye = buttons(&mut u, "Hidden"); + let x = if mirrored { 1158.0 } else { 262.0 }; + assert_eq!(eye.iter().map(|r| (r.min.x, r.max.x)).collect::>(), [(x, x + 20.0)], "{count} rows, mirrored {mirrored}"); + } + } +} + +/// Review: while a sweep across the eyes is held, a long-named row it took in shows its eye, so its +/// name stays clipped before the eye after the pointer has moved past it. +#[test] +fn a_swept_long_named_row_keeps_its_name_clipped_before_the_eye() { + let mut s = Session::new(); + let long = named(&mut s, LONG, None); + let short = named(&mut s, "Short", None); + let mut u = Ui::new(s); + u.ctx.enable_accesskit(); + let at = u.row_at(short); + u.frame(vec![Event::PointerMoved(at)]); + let eye = *buttons(&mut u, "Hidden").first().expect("the hovered row's eye"); + let below = u.row_at(long) + vec2(0.0, 40.0); + u.frame(vec![Event::PointerMoved(eye.center())]); + u.drag_to(eye.center(), Pos2::new(eye.center().x, below.y)); + let out = u.frame_output(vec![]); + let clip = out + .shapes + .iter() + .find_map(|c| match &c.shape { + Shape::Text(t) if t.galley.text().starts_with("Size=small") => Some(c.clip_rect), + _ => None, + }) + .expect("the long name"); + u.button(Pos2::new(eye.center().x, below.y), false); + let doc = u.app.session.doc().unwrap(); + assert!(!doc.node(long).unwrap().visible && !doc.node(short).unwrap().visible, "the sweep hid both"); + assert!(clip.max.x <= eye.min.x - 20.0, "the name ends before the padlock and eye: {} vs eye at {}", clip.max.x, eye.min.x); +} + +/// Review: on a row nested so deep that its disclosure triangle sits where the eye and padlock +/// would be at the view's edge, they stay at the row's end, so the triangle still opens and closes +/// the layer. +#[test] +fn the_disclosure_triangle_of_a_deeply_nested_row_is_not_under_the_padlock() { + let mut s = Session::new(); + let mut parent = None; + let mut deepest = None; + for i in 0..13 { + let f = id(s + .execute("frame.create", &json!({"x": 0, "y": 0, "width": 100, "height": 100, "parent": parent, "props": {"name": format!("F{i}")}})) + .unwrap()); + parent = Some(f); + deepest = Some(f); + } + let deepest = deepest.unwrap(); + let leaf = named(&mut s, "Leaf", parent); + s.execute("select.set", &json!({"ids": [leaf]})).unwrap(); + let mut u = Ui::new(s); + u.ctx.enable_accesskit(); + let tri = *buttons(&mut u, "Collapse").last().expect("the deepest frame's triangle"); + u.frame(vec![Event::PointerMoved(tri.center())]); + u.frame(vec![Event::PointerMoved(tri.center())]); + u.button(tri.center(), true); + u.button(tri.center(), false); + u.frame(vec![]); + assert!(!u.app.ui.expanded.contains(&deepest), "the triangle closed the frame"); + let n = u.app.session.doc().unwrap().node(deepest).unwrap(); + assert!(n.visible && !n.locked, "neither the eye nor the padlock took the click"); +} diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index 4ac78bbef..a07dc13e1 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -556,8 +556,9 @@ pub(crate) fn list_width(ui: &Ui) -> f32 { } /// A name's room on a row stops growing here: a name of thousands of characters (#1650) elides -/// past it instead of making the list that wide. -pub(crate) const NAME_ROOM: f32 = 1200.0; +/// past it instead of making the list that wide. 400 pt still holds a long variant name +/// (`Size=small, Type=primary, State=default, Icon=leading, Width=full`) in full. +pub(crate) const NAME_ROOM: f32 = 400.0; /// A row's name: the layer's, or its kind's label when it has none. fn row_name(n: &figcraft_doc::Node) -> &str { @@ -996,20 +997,34 @@ fn drop_layers(app: &mut FigApp, doc: &Document, moving: &[NodeId], target: Node } } -/// The eye and padlock of a row: painted when hovered (`over`, false in Dev Mode) or set, and, outside -/// Dev Mode, clickable; a drag over them starts a sweep. Returns the layers whose eye / padlock was clicked. -fn eye_lock( - ui: &mut Ui, - t: &Tokens, - rects: [Rect; 2], - row: &Row, - n: &figcraft_doc::Node, - over: bool, - dev: bool, - sweep: &mut Option, -) -> (Option, Option) { - let [r, rr] = rects; - let (mut vis, mut lock) = (None, None); +/// The eye and padlock's span on a row (`rr`, the row inset 8 pt from each side) wider than the view: +/// its end stops 8 pt inside the view's edge, where it is on a row as wide as the view, but never so +/// far in that the buttons cover the row's disclosure triangle, icon or name start (`name_x`, +/// unmirrored). Returns that row span (what [`eye_lock`] places them at the end of) and the +/// buttons' 48 pt: the eye and padlock are 20 pt each, 4 pt from the end and 2 pt apart. +fn row_buttons(rr: Rect, view: Rect, name_x: f32, rtl: bool) -> (Rect, Rect) { + if rtl { + let name_start = rr.min.x + rr.max.x - name_x; + let end = Rect::from_min_max(pos2(rr.min.x.max((view.min.x + 8.0).min(name_start - 48.0)), rr.min.y), rr.max); + return (end, Rect::from_x_y_ranges(end.min.x..=(end.min.x + 48.0), rr.y_range())); + } + let end = Rect::from_min_max(rr.min, pos2(rr.max.x.min((view.max.x - 8.0).max(name_x + 48.0)), rr.max.y)); + (end, Rect::from_x_y_ranges((end.max.x - 48.0)..=end.max.x, rr.y_range())) +} + +/// Where a row's name is drawn: the view, less the eye and padlock's `buttons` while they show, so +/// a long name is clipped before them instead of drawn under them. +fn name_clip(view: Rect, buttons: Rect, buttons_shown: bool, rtl: bool) -> Rect { + match (buttons_shown, rtl) { + (false, _) => view, + (true, false) => Rect::from_x_y_ranges(view.min.x..=view.max.x.min(buttons.min.x), view.y_range()), + (true, true) => Rect::from_x_y_ranges(view.min.x.max(buttons.max.x)..=view.max.x, view.y_range()), + } +} + +/// Whether row `r`'s layer shows as hidden and as locked: what a sweep in progress sets for the rows +/// it took in, else the layer's own state. The row joins the sweep when the pointer is on it. +fn swept_state(ui: &Ui, r: Rect, row: &Row, n: &figcraft_doc::Node, sweep: &mut Option) -> (bool, bool) { // A sweep across the eyes or padlocks takes in the rows the pointer passes. if let Some(sw) = sweep.as_mut() && !sw.ids.contains(&row.id) @@ -1020,9 +1035,26 @@ fn eye_lock( sw.ids.push(row.id); } let swept = |lock: bool| sweep.as_ref().filter(|sw| sw.lock == lock && sw.ids.contains(&row.id)).map(|sw| sw.on); + (swept(false).unwrap_or(!n.visible), swept(true).unwrap_or(n.locked)) +} + +/// The eye and padlock of a row, shown `hidden` and `locked` ([`swept_state`]): painted when hovered +/// (`over`, false in Dev Mode) or set, and, outside Dev Mode, clickable; a drag over them starts a +/// sweep. Returns the layers whose eye / padlock was clicked. +fn eye_lock( + ui: &mut Ui, + t: &Tokens, + rects: [Rect; 2], + row: &Row, + n: &figcraft_doc::Node, + (hidden, locked): (bool, bool), + over: bool, + dev: bool, + sweep: &mut Option, +) -> (Option, Option) { + let [r, rr] = rects; + let (mut vis, mut lock) = (None, None); // Lock / eye on hover (or when set); a layer in a locked one shows a faint padlock. - let hidden = swept(false).unwrap_or(!n.visible); - let locked = swept(true).unwrap_or(n.locked); // In Dev Mode they only show what is set. let show_lock = over || locked || row.locked_above; let show_eye = over || hidden; @@ -1293,6 +1325,8 @@ fn layers(app: &mut FigApp, ui: &mut Ui) { let icon_rect = Rect::from_center_size(pos2(fx(x0 + 22.0), r.center().y), vec2(14.0, 14.0)); icons::paint(ui.painter(), icon_rect, icon, icon_col); let name_x = x0 + 36.0; + let (buttons_end, buttons) = row_buttons(rr, ui.clip_rect(), name_x, rtl); + let toggles = swept_state(ui, r, row, n, &mut sweep); if app.ui.rename.is_some_and(|rn| rn.id == row.id) { if let Some(new) = rename_field(app, ui, row.id, row.depth, &n.name, r) { rename_done = Some((row.id, new)); @@ -1304,9 +1338,11 @@ fn layers(app: &mut FigApp, ui: &mut Ui) { // Room before the lock and eye buttons (the row is wide enough for the whole // name, up to `NAME_ROOM`: a row widened by a deeper name gives no more). let max_w = (rr.max.x - 56.0 - name_x).clamp(20.0, NAME_ROOM); - crate::bidi::paint_name_from(ui.painter(), pos2(fx(name_x), r.center().y), rtl, &name, font, col, max_w); + let buttons_shown = (over && !dev) || toggles.0 || toggles.1 || row.locked_above; + let clip = name_clip(ui.clip_rect(), buttons, buttons_shown, rtl); + crate::bidi::paint_name_from(&ui.painter().with_clip_rect(clip), pos2(fx(name_x), r.center().y), rtl, &name, font, col, max_w); } - let (v, l) = eye_lock(ui, &t, [r, rr], row, n, over && !dev, dev, &mut sweep); + let (v, l) = eye_lock(ui, &t, [r, buttons_end], row, n, toggles, over && !dev, dev, &mut sweep); vis = v.or(vis); lock = l.or(lock); if resp.clicked() { diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..eb4450f7f 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (the Layers panel's eye and padlock stay at the list's right edge, and a name takes at most 400 pt; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -184,7 +184,7 @@ in the table. `crates/ui-egui/src/shortcut_keys_tests.rs` drives the keys a look | Screen-reader names, roles, values, states (AccessKit) | done on desktop | browser: eframe doesn't send the tree yet | | Keyboard navigation: F6 regions, Tab within, focus ring | done | | | Layers panel from the keyboard: arrows, F2 / Cmd+R rename (the row gets the keyboard back), Shift+F10 context menu; 10k-layer lists | done | revealing a layer, expanding, collapsing and arrow keys timed in `cargo xtask bench` | -| Layers panel: long or deeply nested names | done | the list is as wide as its widest name needs and scrolls sideways, so a name reads in full without widening the sidebar (the reference app's Layers panel has a horizontal scrollbar); a drag released over the canvas drops nowhere; a name past 1200 pt still elides (`layers_wide_names_tests`, #1904) | +| Layers panel: long or deeply nested names | done | the list is as wide as its widest name needs and scrolls sideways, so a name reads in full without widening the sidebar (the reference app's Layers panel has a horizontal scrollbar); a drag released over the canvas drops nowhere; a name past 400 pt elides, and the eye and padlock stay at the edge of the list's view (`layers_wide_names_tests`, #1904) | | Reduced motion | done | system setting or preference | | WCAG AA contrast of secondary and accent text | done | disabled and dim text at least 3:1 against panels, fields and selected rows, selected text at least 3:1 on its highlight, in both themes (`theme::tests`, #890) | | Tested with VoiceOver, NVDA, Narrator, Orca | missing | human QA | @@ -219,6 +219,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | 2026-11-19 | patch | M5, #2360: with a frame selected, a drag that starts on one of its children moves the frame and a click selects the child (a press on a layer inside a selected one drags the selection), as in Figma; Cmd/Ctrl, Shift and layers outside the frame are unchanged. | | 2026-11-18 | patch | M5, #2372: the arrow keys move a layer along the canvas axes inside a rotated parent (the step was applied along the parent's axes, so Down moved a child of a frame rotated 90 degrees sideways); auto layout children are unchanged | | 2026-11-18 | patch | M1, #2355: Cmd/Ctrl+V with one layer inside a frame selected pasted the copy onto the page on top of the frame; it now goes into the layer's parent just above it (in an auto layout frame, the item after it, so the layout grows), keeping today's behaviour for a page-level layer, several layers, an instance's children and a board atom. Tests: `paste_sibling_tests` (5) | +| 2026-11-18 | patch | M3, #1904 follow-up: a text layer named after a paragraph made the Layers list over 1000 pt wide, and the eye and padlock sat at the far end of each row, so hiding a layer meant scrolling sideways. They now sit at the right edge of the list's view, with the name clipped under them while they show (hover, or a hidden or locked layer), and a name takes at most 400 pt instead of 1200, which still holds a variant name like `Size=small, Type=primary, State=default, Icon=leading, Width=full` in full. A row nested so deep that its disclosure triangle would sit under them keeps them at its end, and a row a held sweep has taken in keeps its name clipped; an ordinary row's eye is where it was. Tests: `the_eye_of_a_long_named_layer_sits_at_the_panels_edge_and_is_clickable`, `a_paragraph_named_text_layer_widens_the_list_no_more_than_the_name_cap`, `the_eye_of_an_ordinary_row_stays_where_it_was`, `a_swept_long_named_row_keeps_its_name_clipped_before_the_eye`, `the_disclosure_triangle_of_a_deeply_nested_row_is_not_under_the_padlock` | | 2026-11-08 | minor | M8, #2109: in vector edit mode the Align commands (`align.left` to `align.bottom`, Alt+A/H/D/W/V/S) and Distribute horizontal and vertical spacing act on the selected points when neither `ids` nor `id` is given (either one targets layers), as in Figma (measured in Figma on 2026-11-08): each point moves along one axis only, to its box's left, horizontal centre, right, top, vertical centre or bottom, and distribute spaces the points evenly between the outermost two in order along the axis; handles go with their vertex, a single point stays, with no point selected nothing moves (the layer is not aligned to its frame, as measured in Figma), and one undo restores them. The Design panel draws the alignment row first, with a Distribute menu from three points. Numbers unchanged. | | 2026-11-08 | patch | Number fields: scrubbing a label moves half a step a point, not a step, as measured in Figma (X from 100: +6 for a 12.2 px drag, +31 for 61.2 px; rotation 6° and opacity 5% for 12.2 px); Shift (x10), Alt (x0.1) and the speed by height are kept on top of it and were not measured, and no field's scrub direction changed | | 2026-11-17 | patch | M8: each page keeps its view in a session: going back to a page (the Pages list, `page.select`, Previous/Next page) shows it where it was left instead of fitting it again; a new page is still fitted, and going to the page shown moves nothing (`page_view_tests`) | From 167ce234bc9e298bde4c0a2513865296029b6651 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Wed, 18 Nov 2026 18:39:13 -0500 Subject: [PATCH 11/36] M3: Library styles show in the style pickers without the Assets tab, with a source menu Enabled libraries were read from disk only by the Assets panel (refresh_libraries ran from its show). After a file with enabled libraries was opened, the Design panel's style pickers found none in the cache, and a library's text styles weren't offered ("No text styles yet") until the Assets tab had been opened once. refresh_libraries now runs from the app's background tick, whichever tab shows, and reads a local library not read yet at once instead of waiting out the 2 s throttle. A library the read refuses (too large, or not on this computer) is never cached, so the tick remembers the paths it last tried and tries those again only after the throttle; otherwise it would read again every frame. The periodic repaint that picks up a library changed on disk stays with the Assets panel, so an idle window isn't woken every 2 s; the panel's doc comment now describes that repaint. The style picker gets Figma's source menu under the search field when the file has enabled libraries: All libraries (the default, the list as before), This file, or one library, kept while the picker is open. A library that goes away falls back to All libraries. --- crates/ui-egui/locales/en.toml | 1 + crates/ui-egui/locales/ru.toml | 1 + crates/ui-egui/src/app/commands.rs | 1 + crates/ui-egui/src/panels/assets_panel.rs | 40 +++++++---- crates/ui-egui/src/widgets/style_picker.rs | 68 +++++++++++++++++-- .../ui-egui/src/widgets/style_picker/tests.rs | 68 +++++++++++++++++++ docs/components-parity.md | 3 +- 7 files changed, 162 insertions(+), 20 deletions(-) diff --git a/crates/ui-egui/locales/en.toml b/crates/ui-egui/locales/en.toml index e42a1c21c..c03f7ad65 100644 --- a/crates/ui-egui/locales/en.toml +++ b/crates/ui-egui/locales/en.toml @@ -102,6 +102,7 @@ name = "English" "All comments" = "All comments" "All components" = "All components" "All fonts" = "All fonts" +"All libraries" = "All libraries" "All objects" = "All objects" "All supported properties" = "All supported properties" "All the fonts this file uses are installed" = "All the fonts this file uses are installed" diff --git a/crates/ui-egui/locales/ru.toml b/crates/ui-egui/locales/ru.toml index bc7aa6353..f74c0c02a 100644 --- a/crates/ui-egui/locales/ru.toml +++ b/crates/ui-egui/locales/ru.toml @@ -99,6 +99,7 @@ name = "Русский" "All comments" = "Все комментарии" "All components" = "Все компоненты" "All fonts" = "Все шрифты" +"All libraries" = "Все библиотеки" "All objects" = "Все объекты" "All supported properties" = "Все поддерживаемые свойства" "All the fonts this file uses are installed" = "Все шрифты, которые использует этот файл, установлены" diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index e36471b42..e3251fcdd 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -321,6 +321,7 @@ impl FigApp { self.autosave_tick(ctx, now); self.auto_save_tick(ctx, now); updates_ui::tick(self, ctx); + crate::assets_panel::refresh_libraries(self, ctx); self.logic_ticked = true; } } diff --git a/crates/ui-egui/src/panels/assets_panel.rs b/crates/ui-egui/src/panels/assets_panel.rs index 9ee6c0dfe..a5f3773bc 100644 --- a/crates/ui-egui/src/panels/assets_panel.rs +++ b/crates/ui-egui/src/panels/assets_panel.rs @@ -37,9 +37,9 @@ const MAX_THUMBS: usize = 600; const THUMBS_PER_FRAME: usize = 8; /// Layers compared per component when checking whether its thumbnail is stale. const MAX_COMPARED: usize = 20_000; -/// Look for changed library files this often (seconds) while the panel shows. +/// Look for changed library files this often (seconds). const LIBRARY_REFRESH: f64 = 2.0; -/// Ask team libraries' servers for newer versions this often (seconds) while the panel shows. +/// Ask team libraries' servers for newer versions this often (seconds). // shortcut: polled (a few bytes when nothing changed); a server push needs a connection per // library, worth it once libraries are used beyond the Assets panel. const SERVER_REFRESH: f64 = 30.0; @@ -278,33 +278,42 @@ fn build_listing(app: &FigApp, doc: &Document, q: &str, key: (u64, String, u64)) Listing { key, local: foldered("", local), local_styles, libraries, updates } } -/// Re-read enabled library files that changed on disk (throttled). -fn refresh_libraries(app: &mut FigApp, ui: &Ui) { +/// Re-read enabled library files that changed on disk (throttled), every logic tick whether or not +/// the Assets panel shows, so the style pickers list library styles too. A library this file +/// hasn't tried to read yet (just opened or added) is read at once. +pub(crate) fn refresh_libraries(app: &mut FigApp, ctx: &egui::Context) { let Ok(doc) = app.session.doc() else { return }; if doc.libraries.enabled.is_empty() { return; } let paths: Vec = doc.libraries.enabled.iter().map(|l| l.path.clone()).collect(); let id = Id::unique("asset_libraries_checked"); - let now = ui.input(|i| i.time); - let last: Option = ui.data(|d| d.get_temp(id)); - if last.is_none_or(|l| now - l >= LIBRARY_REFRESH) { + // The paths the last read tried: one that was refused (too large, not on this computer) is + // never cached, and would otherwise be tried again every frame. + let tried_id = Id::unique("asset_libraries_tried"); + let now = ctx.input(|i| i.time); + let last: Option = ctx.data(|d| d.get_temp(id)); + let tried: Vec = ctx.data(|d| d.get_temp(tried_id)).unwrap_or_default(); + let unread_here = paths.iter().any(|p| !is_server_link(p) && app.session.libraries.cached(p).is_none() && !tried.contains(p)); + if unread_here || last.is_none_or(|l| now - l >= LIBRARY_REFRESH) { for p in &paths { let _ = app.session.libraries.load(p); } - ui.data_mut(|d| d.insert_temp(id, now)); + ctx.data_mut(|d| { + d.insert_temp(id, now); + d.insert_temp(tried_id, paths.clone()); + }); // Team libraries: in the background, at once for one not fetched yet. let sid = Id::unique("asset_server_libraries_checked"); - let fetched: Option = ui.data(|d| d.get_temp(sid)); + let fetched: Option = ctx.data(|d| d.get_temp(sid)); // Only the ones you added or checked: a file can't make the app contact a server (#1097). let team: Vec<&String> = paths.iter().filter(|p| is_server_link(p) && app.session.library_allowed(p)).collect(); let unread = team.iter().any(|p| app.session.libraries.cached(p).is_none()); if !team.is_empty() && (unread || fetched.is_none_or(|l| now - l >= SERVER_REFRESH)) { app.session.refresh_server_libraries(); - ui.data_mut(|d| d.insert_temp(sid, now)); + ctx.data_mut(|d| d.insert_temp(sid, now)); } } - ui.ctx().request_repaint_after(std::time::Duration::from_secs_f64(LIBRARY_REFRESH)); } /// The search field with the libraries button; returns the lowercase query. @@ -577,12 +586,15 @@ fn render_thumbs(ui: &Ui, w: f32, thumbs: &mut Thumbs, wanted: &[(Source, NodeId } } -/// Draw the Assets panel: refresh libraries, switch to the libraries view when asked, -/// otherwise cache a listing keyed by revision, query and library state, render local and +/// Draw the Assets panel: repaint every `LIBRARY_REFRESH` while the file has libraries (so a +/// library changed on disk shows; the app's tick reads it), switch to the libraries view when +/// asked, otherwise cache a listing keyed by revision, query and library state, render local and /// enabled-library assets with reused thumbnails, and dispatch place, style, hide, toggle /// and drag actions. pub fn show(app: &mut FigApp, ui: &mut Ui) { - refresh_libraries(app, ui); + if app.session.doc().is_ok_and(|d| !d.libraries.enabled.is_empty()) { + ui.ctx().request_repaint_after(std::time::Duration::from_secs_f64(LIBRARY_REFRESH)); + } if app.ui.libraries { libraries_view(app, ui); return; diff --git a/crates/ui-egui/src/widgets/style_picker.rs b/crates/ui-egui/src/widgets/style_picker.rs index ca063abad..fb369fbca 100644 --- a/crates/ui-egui/src/widgets/style_picker.rs +++ b/crates/ui-egui/src/widgets/style_picker.rs @@ -160,6 +160,30 @@ pub struct Picker { y: f32, query: String, edit: Option, + /// Whose styles the list shows (the source menu over the list). + source: Source, +} + +/// The source menu's choice: every source, this file's styles, or one enabled library's (by +/// manifest id). +#[derive(Clone, Debug, Default, PartialEq)] +enum Source { + #[default] + All, + ThisFile, + Library(String), +} + +impl Source { + /// Whether the styles of `lib` (`None`: this file) are listed. + fn shows(&self, lib: Option<&PublishedLibrary>) -> bool { + match (self, lib) { + (Source::All, _) => true, + (Source::ThisFile, None) => true, + (Source::Library(id), Some(l)) => l.manifest.id == *id, + _ => false, + } + } } impl Picker { @@ -174,7 +198,7 @@ pub fn open(app: &mut FigApp, ui: &Ui, ids: &[NodeId], slot: StyleSlot) { // Opening the style picker closes the colour picker (it would linger beside it). crate::colorpicker::close(app); app.ui.style_picker_popover = None; - app.ui.style_picker = Some(Picker { slot, ids: ids.to_vec(), y, query: String::new(), edit: None }); + app.ui.style_picker = Some(Picker { slot, ids: ids.to_vec(), y, query: String::new(), edit: None, source: Source::All }); } /// Open the picker for `slot` of the selection (the control channel), optionally editing `style`. @@ -183,7 +207,7 @@ pub fn open_for_selection(app: &mut FigApp, slot: StyleSlot, style: Option<&str> let edit = style.and_then(|s| app.session.doc().ok()?.style(s).map(editing)); crate::colorpicker::close(app); app.ui.style_picker_popover = None; - app.ui.style_picker = Some(Picker { slot, ids, y: 140.0, query: String::new(), edit }); + app.ui.style_picker = Some(Picker { slot, ids, y: 140.0, query: String::new(), edit, source: Source::All }); } fn editing(s: &Style) -> Editing { @@ -522,6 +546,28 @@ fn offered<'a>(doc: &'a Document, lib: Option<&'a PublishedLibrary>, slot: Style } } +/// The source menu over the style list (shown when the file has libraries): All libraries, This +/// file, then each library by name, the chosen one ticked. +fn source_menu(ui: &mut Ui, libs: &[std::sync::Arc], source: &mut Source) { + let label = match source { + Source::All => tr("All libraries").to_string(), + Source::ThisFile => tr("This file").to_string(), + Source::Library(id) => libs.iter().find(|l| l.manifest.id == *id).map(|l| l.manifest.name.clone()).unwrap_or_default(), + }; + let resp = widgets::dropdown(ui, &label, W, None); + crate::right::menu_popup(&resp).width(W).show(|ui| { + let mut choices = vec![(Source::All, tr("All libraries").to_string()), (Source::ThisFile, tr("This file").to_string())]; + choices.extend(libs.iter().map(|l| (Source::Library(l.manifest.id.clone()), l.manifest.name.clone()))); + for (choice, name) in choices { + let mark = if *source == choice { "✓ " } else { " " }; + if crate::right::menu_item(ui, &format!("{mark}{name}"), "") { + *source = choice; + ui.close(); + } + } + }); +} + /// The style list: header, search, this file's and the libraries' styles by folder, and (colour /// slots) colour variables. fn listing(app: &FigApp, ui: &mut Ui, doc: &Document, p: &mut Picker, out: &mut Frame) { @@ -560,8 +606,20 @@ fn listing(app: &FigApp, ui: &mut Ui, doc: &Document, p: &mut Picker, out: &mut ui.add_space(4.0); let q = p.query.trim().to_lowercase(); let libs = crate::variable_ui::libraries(app, doc); - let mut sources: Vec<(Option<&PublishedLibrary>, Vec<&Style>)> = vec![(None, offered(doc, None, slot, &q))]; - for l in &libs { + if !libs.is_empty() { + source_menu(ui, &libs, &mut p.source); + ui.add_space(4.0); + } + if let Source::Library(id) = &p.source + && !libs.iter().any(|l| l.manifest.id == *id) + { + p.source = Source::All; + } + let mut sources: Vec<(Option<&PublishedLibrary>, Vec<&Style>)> = Vec::new(); + if p.source.shows(None) { + sources.push((None, offered(doc, None, slot, &q))); + } + for l in libs.iter().filter(|l| p.source.shows(Some(l))) { let list = offered(doc, Some(l), slot, &q); if !list.is_empty() { sources.push((Some(l.as_ref()), list)); @@ -1246,7 +1304,7 @@ fn edit_local(app: &mut FigApp, ui: &Ui, slot: StyleSlot, id: &str) { let edit = app.session.doc().ok().and_then(|d| d.style(id).map(editing)); crate::colorpicker::close(app); app.ui.style_picker_popover = None; - app.ui.style_picker = Some(Picker { slot, ids: app.session.selection(), y, query: String::new(), edit }); + app.ui.style_picker = Some(Picker { slot, ids: app.session.selection(), y, query: String::new(), edit, source: Source::All }); } /// `style.move` for the shown style `from` dropped at shown position `to` (`shown` in display diff --git a/crates/ui-egui/src/widgets/style_picker/tests.rs b/crates/ui-egui/src/widgets/style_picker/tests.rs index 08c27f12d..e837d3fa6 100644 --- a/crates/ui-egui/src/widgets/style_picker/tests.rs +++ b/crates/ui-egui/src/widgets/style_picker/tests.rs @@ -572,3 +572,71 @@ fn style_picker_icon_buttons_paint_16pt() { assert!(paints_icon_at_button_size(&painted, icon), "{icon:?} is not 16 pt"); } } + +#[test] +fn a_reopened_files_text_styles_picker_lists_its_librarys_styles_without_the_assets_tab() { + let dir = std::env::temp_dir().join(format!("figcraft-picker-library-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir(&dir).unwrap(); + let (library, file) = (dir.join("ds.figcraft"), dir.join("site.figcraft")); + let mut publisher = Session::new(); + publisher.execute("style.create", &json!({"type": "text", "name": "Display", "value": {"fontFamily": "Inter", "fontSize": 48}})).unwrap(); + publisher.execute("library.publish", &json!({})).unwrap(); + publisher.execute("file.saveAs", &json!({"path": library})).unwrap(); + let mut site = Session::new(); + site.execute("text.create", &json!({"text": "Hello", "x": 0, "y": 0})).unwrap(); + site.execute("style.create", &json!({"type": "text", "name": "Body", "value": {"fontFamily": "Inter", "fontSize": 14}})).unwrap(); + site.execute("library.add", &json!({"path": library})).unwrap(); + site.execute("file.saveAs", &json!({"path": file})).unwrap(); + + let mut reopened = Session::new(); + reopened.execute("file.open", &json!({"path": file})).unwrap(); + let text = reopened.doc().unwrap().nodes().find(|n| matches!(n.kind, figcraft_doc::NodeKind::Text(_))).unwrap().id; + reopened.execute("select.set", &json!({"ids": [text]})).unwrap(); + let mut u = crate::layers_drag_tests::Ui::new(reopened); + open_for_selection(&mut u.app, StyleSlot::Text, None); + for _ in 0..3 { + u.frame(vec![]); + } + let texts = drawn_texts(&mut u); + let _ = std::fs::remove_dir_all(&dir); + let (display, body) = ("48/Auto", "14/Auto"); + let shows = |texts: &[(String, Pos2)], s: &str| texts.iter().any(|(t, _)| t == s); + assert!(shows(&texts, display) && shows(&texts, body), "every source by default: {:?}", texts.iter().map(|t| &t.0).collect::>()); + + let choose = |u: &mut crate::layers_drag_tests::Ui, from: &str, to: &str| { + let at = text_at(&drawn_texts(u), from); + u.button(at, true); + u.button(at, false); + let texts = drawn_texts(u); + let item = texts.iter().rev().find(|(t, _)| t.trim_start_matches(['✓', ' ']) == to).unwrap_or_else(|| panic!("{to} in the menu")).1; + u.button(item, true); + u.button(item, false); + drawn_texts(u) + }; + let texts = choose(&mut u, "All libraries", "This file"); + assert!(shows(&texts, body) && !shows(&texts, display), "This file: its own styles only"); + let texts = choose(&mut u, "This file", "Untitled"); + assert!(shows(&texts, display) && !shows(&texts, body), "a library: its styles only"); + assert!(u.app.ui.style_picker.is_some(), "choosing a source keeps the picker open"); +} + +#[test] +fn a_library_that_cant_be_read_is_tried_again_only_after_the_refresh_interval() { + let mut s = Session::new(); + s.doc_mut().unwrap().libraries_mut().enabled.push(figcraft_doc::LibraryLink { + id: "elsewhere".into(), + name: "Elsewhere".into(), + path: "file://server/share/ds.figcraft".into(), + relative: String::new(), + version: 0, + }); + let mut u = crate::layers_drag_tests::Ui::new(s); + let checked = |u: &crate::layers_drag_tests::Ui| u.ctx.data(|d| d.get_temp::(Id::unique("asset_libraries_checked"))); + u.frame(vec![]); + let first = checked(&u).expect("the first frame tries the library"); + for _ in 0..10 { + u.frame(vec![]); + } + assert_eq!(checked(&u), Some(first), "a refused library doesn't make every frame read again"); +} diff --git a/docs/components-parity.md b/docs/components-parity.md index fa4d2494e..02b0ca441 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (an enabled library's styles are offered in the style pickers without opening the Assets tab first, and the picker filters its list by source (All libraries, This file, one library); a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Date | Change | Summary | |---|---|---| +| 2026-11-18 | patch | M3: enabled libraries were read only while the Assets panel showed, so after a file was opened the Design panel's style pickers offered none of their styles (a library's text styles read "No text styles yet") until the Assets tab had been opened. They are refreshed from the app's background tick now, a local library not read yet at once. The style picker has a source menu under its search field, as in Figma: All libraries (the default), This file, or one enabled library. Test: `style_picker::tests::a_reopened_files_text_styles_picker_lists_its_librarys_styles_without_the_assets_tab` | | 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`::S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. | | 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. | | 2026-11-18 | minor | M3, gap 10: library analytics count insertions and detachments of styles and variables. Applying one, or copying or duplicating content that uses it, inserts it; the Detach button detaches it; an instance counts as its component alone. Show usage and `library.usage` give them per style and variable over the chosen period. Modes aren't counted. Numbers unchanged. Tests: `library_asset_counts_tests`, `library_assets_tests`. | From 406bbf7aba5073f6d07b113654989939eb7c32ce Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:25:37 -0500 Subject: [PATCH 12/36] M4: Text pasted while editing keeps its formatting; Shift+Cmd/Ctrl+V matches the style Text copied or cut while editing reached the clipboard as plain characters, and a paste inserted them in the style at the caret, so the copied font, size, colour and text style were lost. A whole text layer copied with Cmd/Ctrl+C and pasted into another text's edit lost them the same way. Shift+Cmd/Ctrl+V and Alt+Cmd/Ctrl+V while editing did nothing useful: on the desktop egui-winit sends those chords as keys, and no text binding took them. A copy or cut while editing now also keeps the selection's style runs (textedit::selected_rich_text), and a copy of text layers keeps theirs (textedit::layers_rich_text, joined with line breaks as the clipboard's text is). A run coloured by its layer's fill carries that fill, since a run without fills of its own takes the fill of whatever layer it lands in. A paste whose text is still that copied text inserts it with those runs (textedit::insert_rich); a run linked to a text style the file doesn't have keeps its look and drops the link, and fills equal to the destination layer's are left to the layer. The copy also carries the data of the images the runs' fills use, and the paste adds it where the file lacks that key, as a layer paste does, so an image fill resolves in another file. Text from another app pastes as before. Shift+Cmd/Ctrl+V while editing, and Alt+Cmd/Ctrl+V, read the clipboard's text and insert it plain, in the style at the caret; in the browser, where the chord also brings a paste event, the event is used and the key only marks the chord as handled, and the chord on that key, not the modifiers held when the event is read, picks the plain paste. Shift alone is another paste key (Shift+Insert) and keeps the formatting. Outside text editing Shift+Cmd/Ctrl+V is still Paste over selection and Alt+Cmd/Ctrl+V Paste properties. --- crates/engine/src/canvas/textedit.rs | 103 +++++++++++- crates/engine/src/canvas/textedit/tests.rs | 49 ++++++ crates/ui-egui/src/lib.rs | 6 + crates/ui-egui/src/menus.rs | 2 + crates/ui-egui/src/shortcuts.rs | 40 ++++- crates/ui-egui/src/text_paste_style_tests.rs | 160 +++++++++++++++++++ docs/ui-parity.md | 3 +- 7 files changed, 360 insertions(+), 3 deletions(-) create mode 100644 crates/ui-egui/src/text_paste_style_tests.rs diff --git a/crates/engine/src/canvas/textedit.rs b/crates/engine/src/canvas/textedit.rs index 6c8c15071..ce592775f 100644 --- a/crates/engine/src/canvas/textedit.rs +++ b/crates/engine/src/canvas/textedit.rs @@ -1,8 +1,9 @@ //! On-canvas text editing: caret, selection, typing. A whole editing session is one undo step. +use std::collections::BTreeMap; use std::sync::{LazyLock, Mutex}; -use figcraft_doc::{Document, ListStyle, NodeId, NodeKind, TextData}; +use figcraft_doc::{Document, ImageData, ListStyle, NodeId, NodeKind, TextData}; use crate::{EngineError, Preedit, Result, Session, TextEdit}; @@ -856,6 +857,106 @@ pub fn selected_text(s: &Session) -> Option { Some(t.characters.chars().skip(a).take(b.saturating_sub(a)).collect()) } +/// Copied characters with their formatting, for a paste into a text edit that keeps it. +#[derive(Clone, Debug, PartialEq)] +pub struct RichText { + pub text: String, + /// Styled runs as `(from, to, style)` char ranges of `text`. Each style carries its fills, + /// the layer's own where the run had none, so the characters keep their colour elsewhere. + pub spans: Vec<(usize, usize, figcraft_doc::TextStyle)>, + /// The data of the images the runs' fills use, so they resolve in another file. + pub images: BTreeMap, +} + +/// The selected characters while editing, with their formatting (for copy). +pub fn selected_rich_text(s: &Session) -> Option { + let (id, a, b) = selected_range(s)?; + rich_text_of(s.doc().ok()?, id, a, b) +} + +/// The characters of the text layers `ids`, one per line, with their formatting; None when one of +/// them isn't a text layer or there are no characters. +pub fn layers_rich_text(doc: &Document, ids: &[NodeId]) -> Option { + let mut joined = RichText { text: String::new(), spans: Vec::new(), images: BTreeMap::new() }; + let mut offset = 0; + for (i, id) in ids.iter().enumerate() { + let layer = rich_text_of(doc, *id, 0, usize::MAX)?; + if i > 0 { + joined.text.push('\n'); + offset += 1; + } + joined.text.push_str(&layer.text); + joined.spans.extend(layer.spans.into_iter().map(|(from, to, style)| (from + offset, to + offset, style))); + joined.images.extend(layer.images); + offset += layer.text.chars().count(); + } + (!joined.text.is_empty()).then_some(joined) +} + +/// Chars `a..b` of the text layer `id` (`b` past the end means to the end), with their formatting. +fn rich_text_of(doc: &Document, id: NodeId, a: usize, b: usize) -> Option { + let n = doc.node(id)?; + let t = n.kind.text()?; + let b = b.min(t.char_count()); + let text: String = t.characters.chars().skip(a).take(b.saturating_sub(a)).collect(); + let spans: Vec<(usize, usize, figcraft_doc::TextStyle)> = t + .spans() + .into_iter() + .filter(|(from, to, _)| *to > a && *from < b) + .map(|(from, to, style)| { + let mut style = style.clone(); + style.fills.get_or_insert_with(|| n.fills.clone()); + (from.max(a) - a, to.min(b) - a, style) + }) + .collect(); + let mut images = BTreeMap::new(); + for paint in spans.iter().flat_map(|(_, _, style)| style.fills.iter().flatten()) { + if let figcraft_color::PaintKind::Image(img) = &paint.kind + && let Some(d) = doc.images.get(&img.image) + { + images.insert(img.image.clone(), d.clone()); + } + } + Some(RichText { text, spans, images }) +} + +/// Replace the selection in the text edit with `rich`, keeping its formatting. A link to a style +/// this file doesn't have is dropped, a fill equal to the layer's is left to the layer, and the +/// copied image data is added where this file lacks the key, as a pasted layer's is. +pub fn insert_rich(s: &mut Session, rich: &RichText) -> Result<()> { + if s.ds()?.text_edit.is_some() { + let doc = s.doc_mut()?; + for (k, v) in &rich.images { + doc.images.entry(k.clone()).or_insert_with(|| v.clone()); + } + } + let doc = s.doc()?; + let layer_fills = s.ds()?.text_edit.as_ref().and_then(|te| doc.node(te.id)).map(|n| n.fills.clone()); + let spans: Vec<(usize, usize, figcraft_doc::TextStyle)> = rich + .spans + .iter() + .map(|(from, to, style)| { + let mut style = style.clone(); + if style.style_id.as_deref().is_some_and(|id| doc.style(id).is_none()) { + style.style_id = None; + } + if style.fills == layer_fills { + style.fills = None; + } + (*from, *to, style) + }) + .collect(); + edit(s, |t, te| { + let (a, b) = range(te); + t.replace_range(a, b, &rich.text); + for (from, to, style) in &spans { + t.restyle(a + from, a + to, |x| *x = style.clone()); + } + te.caret = a + rich.text.chars().count(); + te.anchor = te.caret; + }) +} + /// The selected range while editing (for styling commands), or None. pub fn selected_range(s: &Session) -> Option<(NodeId, usize, usize)> { let te = s.ds().ok()?.text_edit.clone()?; diff --git a/crates/engine/src/canvas/textedit/tests.rs b/crates/engine/src/canvas/textedit/tests.rs index 81756901d..e8daa3bf9 100644 --- a/crates/engine/src/canvas/textedit/tests.rs +++ b/crates/engine/src/canvas/textedit/tests.rs @@ -569,3 +569,52 @@ fn an_empty_ime_commit_ends_the_composition_without_inserting_text() { end(&mut s).unwrap(); assert_eq!(insert_ime_commit(&mut s, "").unwrap(), ImeInsertion::Nothing); } + +#[test] +fn rich_text_pastes_its_runs_and_drops_a_link_to_a_style_this_file_lacks() { + let (mut s, id) = setup("ab"); + begin(&mut s, id, Some(2), false).unwrap(); + let mut bold = data(&s, id).style.clone(); + bold.font_style = "Bold".into(); + bold.style_id = Some("from another file".into()); + let plain = data(&s, id).style.clone(); + insert_rich(&mut s, &RichText { text: "XY".into(), spans: vec![(0, 1, bold), (1, 2, plain)], images: Default::default() }).unwrap(); + let t = data(&s, id); + assert_eq!(t.characters, "abXY"); + assert_eq!(t.style_at(2).font_style, "Bold"); + assert_eq!(t.style_at(2).style_id, None, "a link to a style this file doesn't have"); + assert_eq!(t.style_at(3).font_style, "Regular"); + assert_eq!(sel(&s), (4, 4)); + set_caret(&mut s, 2, false).unwrap(); + set_caret(&mut s, 4, true).unwrap(); + let copied = selected_rich_text(&s).unwrap(); + assert_eq!(copied.text, "XY"); + assert_eq!(copied.spans.iter().map(|(a, b, st)| (*a, *b, st.font_style.as_str())).collect::>(), [(0, 1, "Bold"), (1, 2, "Regular")]); +} + +#[test] +fn copied_characters_bring_the_image_their_fill_uses_into_another_file() { + let (mut source, id) = setup("ab"); + let data = figcraft_doc::ImageData { bytes: std::sync::Arc::new(vec![1, 2, 3]), width: 2, height: 2 }; + { + let doc = source.doc_mut().unwrap(); + doc.images.insert("pic".into(), data.clone()); + doc.get_mut(id).unwrap().fills = vec![figcraft_color::Paint::image("pic", figcraft_color::ImageScaleMode::Fill)]; + } + begin(&mut source, id, Some(0), false).unwrap(); + set_caret(&mut source, 2, true).unwrap(); + let copied = selected_rich_text(&source).unwrap(); + let (mut s, target) = setup("cd"); + begin(&mut s, target, Some(2), false).unwrap(); + insert_rich(&mut s, &copied).unwrap(); + assert_eq!(s.doc().unwrap().images.get("pic"), Some(&data), "the run's image fill resolves here"); +} + +#[test] +fn copied_text_layers_join_one_per_line_with_their_runs_in_place() { + let (mut s, first) = setup("ab"); + let second = crate::params::id_of(&s.execute("text.create", &json!({"text": "cdé", "x": 0, "y": 50})).unwrap()["id"]).unwrap(); + let joined = layers_rich_text(s.doc().unwrap(), &[first, second]).unwrap(); + assert_eq!(joined.text, "ab\ncdé"); + assert_eq!(joined.spans.iter().map(|(a, b, _)| (*a, *b)).collect::>(), [(0, 2), (3, 6)]); +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 32d859f6c..4aedc0d02 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -286,6 +286,8 @@ mod text_link_tests; #[cfg(test)] mod text_mixed_fill_tests; #[cfg(test)] +mod text_paste_style_tests; +#[cfg(test)] mod tidy_tests; #[cfg(test)] mod titlebar_tests; @@ -628,6 +630,9 @@ pub struct UiState { /// copy changes the engine clipboard without writing the OS clipboard; the generation then /// no longer matches, so the stale mirror is not mistaken for the user's own copy. pub last_copy_generation: u64, + /// The formatting of the characters last copied as text: a paste into a text edit of those + /// same characters keeps it. + pub text_copy: Option, /// The fill, stroke or effect row highlighted in the Design panel: Cmd/Ctrl+C copies it. pub property_row: Option, /// A paint or effect copied from its row: Cmd/Ctrl+V pastes it while it's the last copy. @@ -775,6 +780,7 @@ impl Default for UiState { last_copy: None, last_copy_generation: 0, + text_copy: None, property_row: None, property_copy: None, after_field: None, diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index b0a7dfaf1..3827378ac 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -209,6 +209,7 @@ pub fn invoke(app: &mut FigApp, id: &str) { .ok() .and_then(|d| d.vector_edit.as_ref()) .is_some_and(|ve| ve.parts().iter().any(|p| !p.vertices.is_empty() || !p.segments.is_empty())); + let rich = doc.filter(|_| !partial).and_then(|d| figcraft_engine::textedit::layers_rich_text(d, &ids)); let mirror = doc.filter(|_| !partial).and_then(|d| text_layers_text(d, &ids).or_else(|| figcraft_svg_export(d, &ids))); let ran = app.run(id, json!({})); // A partial copy put temporary layers on the engine clipboard; mirror their SVG. @@ -223,6 +224,7 @@ pub fn invoke(app: &mut FigApp, id: &str) { app.clipboard_set_text(&text); app.ui.last_copy = Some(text); app.ui.last_copy_generation = app.session.clipboard.layers_generation; + app.ui.text_copy = rich; } } "edit.paste" => paste(app, None, None), diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 1cac67b4b..fc05b571f 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -776,6 +776,10 @@ fn text_keys(app: &mut FigApp, ctx: &Context, events: &[Event], ime_input: Optio let reject_ime = ime_input.is_some_and(|baseline| baseline.interrupted(app)); // A key that ran a shortcut swallows the text it also produced (Alt+. types "≥" on macOS). let mut skip_text = false; + let paste_in_batch = events.iter().any(|e| matches!(e, Event::Paste(_))); + // The browser sends Shift/Alt+Cmd/Ctrl+V's keys along with its paste event: the chord on the + // key, not the modifiers still held when the paste is handled, says to match the style. + let match_style = events.iter().any(|e| matches!(e, Event::Key { key: Key::V, pressed: true, modifiers: m, .. } if match_style_chord(*m))); for ev in events { if reject_ime && matches!(ev, Event::Ime(_)) { continue; @@ -787,9 +791,19 @@ fn text_keys(app: &mut FigApp, ctx: &Context, events: &[Event], ime_input: Optio } } Event::Ime(ime) => ime_event(app, ctx, ime), - Event::Paste(t) => insert_text(app, ctx, t), + Event::Paste(t) => paste_text(app, ctx, t, match_style), Event::Copy => copy_or_cut(app, ctx, false), Event::Cut => copy_or_cut(app, ctx, true), + // On the desktop the chord comes without a paste event: paste the clipboard's characters. + Event::Key { key: Key::V, pressed: true, modifiers: m, .. } if match_style_chord(*m) => { + if !paste_in_batch + && !app.control_synthetic + && let Some(t) = app.services.clipboard_get_text() + { + insert_text(app, ctx, &t); + } + skip_text = true; + } Event::Key { key, physical_key, pressed: true, modifiers: m, .. } if text_key_event(app, ctx, *key, *physical_key, *m) => { skip_text = true; } @@ -813,6 +827,29 @@ fn insert_text(app: &mut FigApp, ctx: &Context, t: &str) { } } +/// Shift or Alt with Cmd/Ctrl, the Paste and match style chord with V. Shift alone is another +/// paste key (Shift+Insert), which keeps the copied formatting. +fn match_style_chord(m: Modifiers) -> bool { + m.command && (m.alt || m.shift) +} + +/// Paste `t` into the edit: with the formatting it was copied with when it's the characters +/// FigCraft last copied and `match_style` is off, otherwise in the style at the caret. +fn paste_text(app: &mut FigApp, ctx: &Context, t: &str, match_style: bool) { + let pasted = t.replace("\r\n", "\n").replace('\r', "\n"); + let Some(copied) = app.ui.text_copy.clone().filter(|c| !match_style && c.text == pasted) else { + insert_text(app, ctx, t); + return; + }; + let before = ime_stamp(app); + if let Err(e) = figcraft_engine::textedit::insert_rich(&mut app.session, &copied) { + app.toast(e.to_string()); + } + if ime_stamp(app) != before { + note_ime_application_change(app, ctx); + } +} + /// An IME commit, preedit or surrounding-text deletion for the edit. fn ime_event(app: &mut FigApp, ctx: &Context, ev: &egui::ImeEvent) { match ev { @@ -867,6 +904,7 @@ fn copy_or_cut(app: &mut FigApp, ctx: &Context, cut: bool) { && let Some(text) = &selected { app.clipboard_set_text(text); + app.ui.text_copy = figcraft_engine::textedit::selected_rich_text(&app.session); } if cut && selected.is_some() { let _ = figcraft_engine::textedit::key(&mut app.session, "Delete", false, false, false); diff --git a/crates/ui-egui/src/text_paste_style_tests.rs b/crates/ui-egui/src/text_paste_style_tests.rs new file mode 100644 index 000000000..46d33dc6b --- /dev/null +++ b/crates/ui-egui/src/text_paste_style_tests.rs @@ -0,0 +1,160 @@ +//! Pasting into a text edit: characters FigCraft copied keep their formatting, while +//! Shift/Alt+Cmd/Ctrl+V and text from other apps take the style at the caret. +use std::cell::RefCell; +use std::rc::Rc; + +use egui::{Event, Key, Modifiers}; +use figcraft_doc::{NodeId, TextData}; +use figcraft_engine::{Session, textedit}; +use serde_json::json; + +use crate::layers_drag_tests::Ui; + +struct Clipboard(Rc>); + +impl crate::Services for Clipboard { + fn clipboard_set_text(&mut self, text: &str) { + *self.0.borrow_mut() = text.to_string(); + } + fn clipboard_get_text(&mut self) -> Option { + Some(self.0.borrow().clone()) + } +} + +fn text(u: &Ui, id: NodeId) -> TextData { + u.app.session.doc().unwrap().node(id).unwrap().kind.text().unwrap().clone() +} + +fn layer(s: &mut Session, chars: &str, size: f64, y: f64) -> NodeId { + NodeId(s.execute("text.create", &json!({"text": chars, "x": 0, "y": y, "props": {"fontSize": size}})).unwrap()["id"].as_u64().unwrap()) +} + +fn copy_the_bold_word() -> (Ui, NodeId, Rc>) { + let mut s = Session::new(); + let source = layer(&mut s, "Bold plain", 24.0, 0.0); + let target = layer(&mut s, "Target", 12.0, 100.0); + textedit::begin(&mut s, source, Some(0), false).unwrap(); + textedit::set_caret(&mut s, 4, true).unwrap(); + s.execute("text.bold", &json!({})).unwrap(); + let mut u = Ui::new(s); + let clipboard = Rc::new(RefCell::new(String::new())); + u.app.services = Box::new(Clipboard(clipboard.clone())); + u.frame(vec![Event::Copy]); + textedit::end(&mut u.app.session).unwrap(); + textedit::begin(&mut u.app.session, target, Some(6), false).unwrap(); + (u, target, clipboard) +} + +#[test] +fn pasting_copied_text_brings_its_formatting() { + let (mut u, target, clipboard) = copy_the_bold_word(); + assert_eq!(*clipboard.borrow(), "Bold"); + u.frame(vec![Event::Paste("Bold".into())]); + let t = text(&u, target); + assert_eq!(t.characters, "TargetBold"); + assert_eq!((t.style_at(6).font_style.as_str(), t.style_at(6).font_size), ("Bold", 24.0), "the copied characters keep their look"); + assert_eq!((t.style_at(0).font_style.as_str(), t.style_at(0).font_size), ("Regular", 12.0), "the text around them keeps its own"); +} + +#[test] +fn alt_cmd_v_pastes_the_characters_in_the_style_at_the_caret() { + let (mut u, target, _) = copy_the_bold_word(); + let held = Modifiers { alt: true, command: true, mac_cmd: true, ..Modifiers::NONE }; + let v = Event::Key { key: Key::V, physical_key: Some(Key::V), pressed: true, repeat: false, modifiers: held }; + u.frame_with(vec![v], held); + let t = text(&u, target); + assert_eq!(t.characters, "TargetBold"); + assert_eq!((t.style_at(6).font_style.as_str(), t.style_at(6).font_size), ("Regular", 12.0), "the destination's look"); + assert!(t.runs.is_empty()); +} + +#[test] +fn text_copied_elsewhere_pastes_in_the_style_at_the_caret() { + let (mut u, target, _) = copy_the_bold_word(); + u.frame(vec![Event::Paste("From a browser".into())]); + let t = text(&u, target); + assert_eq!(t.characters, "TargetFrom a browser"); + assert!(t.runs.is_empty(), "nothing FigCraft copied: plain text"); +} + +fn painted(s: &mut Session, id: NodeId, hex: &str) { + let paint = figcraft_color::Paint::solid(figcraft_color::Color::from_hex(hex).unwrap()); + s.ds_mut().unwrap().doc_mut().get_mut(id).unwrap().fills = vec![paint]; +} + +fn color_at(u: &Ui, id: NodeId, i: usize) -> Option { + let n = u.app.session.doc().unwrap().node(id).unwrap(); + let fills = n.kind.text().unwrap().style_at(i).fills.clone().unwrap_or_else(|| n.fills.clone()); + fills.first().and_then(figcraft_color::Paint::solid_color) +} + +fn red_source_and_black_target() -> (Ui, NodeId, NodeId) { + let mut s = Session::new(); + let source = layer(&mut s, "Red", 24.0, 0.0); + let target = layer(&mut s, "Target", 12.0, 100.0); + painted(&mut s, source, "#FF0000"); + painted(&mut s, target, "#000000"); + let mut u = Ui::new(s); + u.app.services = Box::new(Clipboard(Rc::new(RefCell::new(String::new())))); + (u, source, target) +} + +#[test] +fn copied_characters_keep_the_colour_of_their_layer() { + let (mut u, source, target) = red_source_and_black_target(); + textedit::begin(&mut u.app.session, source, Some(0), false).unwrap(); + textedit::set_caret(&mut u.app.session, 3, true).unwrap(); + u.frame(vec![Event::Copy]); + textedit::end(&mut u.app.session).unwrap(); + textedit::begin(&mut u.app.session, target, Some(6), false).unwrap(); + u.frame(vec![Event::Paste("Red".into())]); + assert_eq!(text(&u, target).characters, "TargetRed"); + assert_eq!(color_at(&u, target, 6), figcraft_color::Color::from_hex("#FF0000"), "the copied characters stay red"); + assert_eq!(color_at(&u, target, 0), figcraft_color::Color::from_hex("#000000"), "the target's own text stays black"); + assert_eq!(text(&u, target).style_at(6).font_size, 24.0); +} + +#[test] +fn a_copied_text_layer_pastes_into_an_edit_with_its_look() { + let (mut u, source, target) = red_source_and_black_target(); + u.app.session.execute("select.set", &json!({"ids": [source.0]})).unwrap(); + u.frame(vec![Event::Copy]); + textedit::begin(&mut u.app.session, target, Some(6), false).unwrap(); + u.frame(vec![Event::Paste("Red".into())]); + let t = text(&u, target); + assert_eq!(t.characters, "TargetRed"); + assert_eq!(t.style_at(6).font_size, 24.0); + assert_eq!(color_at(&u, target, 6), figcraft_color::Color::from_hex("#FF0000")); + assert_eq!(t.style_at(0).font_size, 12.0); +} + +#[test] +fn shift_cmd_v_pastes_the_characters_in_the_style_at_the_caret() { + let (mut u, target, _) = copy_the_bold_word(); + let held = Modifiers { shift: true, command: true, mac_cmd: true, ..Modifiers::NONE }; + let v = Event::Key { key: Key::V, physical_key: Some(Key::V), pressed: true, repeat: false, modifiers: held }; + u.frame_with(vec![v], held); + let t = text(&u, target); + assert_eq!(t.characters, "TargetBold"); + assert!(t.runs.is_empty(), "the destination's look"); +} + +#[test] +fn shift_insert_is_an_ordinary_paste_and_keeps_the_formatting() { + let (mut u, target, _) = copy_the_bold_word(); + u.frame_with(vec![Event::Paste("Bold".into())], Modifiers::SHIFT); + let t = text(&u, target); + assert_eq!(t.characters, "TargetBold"); + assert_eq!(t.style_at(6).font_style, "Bold"); +} + +#[test] +fn the_chord_matches_the_style_though_its_keys_are_up_by_the_paste() { + let (mut u, target, _) = copy_the_bold_word(); + let chord = Modifiers { shift: true, command: true, mac_cmd: true, ..Modifiers::NONE }; + let v = Event::Key { key: Key::V, physical_key: Some(Key::V), pressed: true, repeat: false, modifiers: chord }; + u.frame_with(vec![v, Event::Paste("Bold".into())], Modifiers::NONE); + let t = text(&u, target); + assert_eq!(t.characters, "TargetBold"); + assert!(t.runs.is_empty(), "the destination's look"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..2e84432cc 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); text copied while editing, or a whole text layer copied, pastes into a text edit with its formatting and its layer's colour, and Shift+Cmd/Ctrl+V (also Alt+Cmd/Ctrl+V) pastes it in the style at the caret; the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-18 | patch | M4: text copied or cut while editing went to the clipboard as plain characters, so Cmd/Ctrl+V put it in the style at the caret and dropped its font, size, fills and text style; Alt+Cmd/Ctrl+V while editing did nothing. Cmd/Ctrl+V now pastes the characters with the formatting they were copied with while the clipboard still holds the text FigCraft copied (a link to a text style the file doesn't have is dropped, its look kept), and Alt+Cmd/Ctrl+V pastes the clipboard's characters in the style at the caret, as Paste and match style does. Characters coloured by their layer's fill keep that colour, and a whole text layer copied with Cmd/Ctrl+C pastes into a text edit the same way. Shift+Cmd/Ctrl+V while editing does what Alt+Cmd/Ctrl+V does; outside text editing it is still Paste over selection. Shift+Insert pastes as Cmd/Ctrl+V does, and an image fill on the copied characters brings its image into another file, as a pasted layer's does. Text copied in another app pastes as before. Tests: `text_paste_style_tests`, `textedit::tests::rich_text_pastes_its_runs_and_drops_a_link_to_a_style_this_file_lacks`, `textedit::tests::copied_characters_bring_the_image_their_fill_uses_into_another_file` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From a28dca47b55d5806b216a16e7e48bc913e58bc38 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:36:58 -0500 Subject: [PATCH 13/36] M1: A curved layer's outline bends smoothly The hover and selection outline of an ellipse, a vector or a rounded corner is the layer's path flattened into lines on screen. The lines could be 0.5 pt from the curve, which made the outline of a 65 by 50 ellipse turn by up to 22 degrees at each point at 100%, and showed its straight pieces at every zoom. The fill, drawn by the renderer, stayed smooth under it. The flattening tolerance is now 0.02 pt on screen for a path with up to 200 curved segments, so the outline stays within a fiftieth of a point of the curve. Above that it grows with the count, up to the old 0.5 pt at 5,000 curves. The hover outline is flattened every frame and the selection outline every frame the view moves, and egui tessellates every point each frame: at a flat 0.02 pt a vector of 5,000 curves had about 4.7 times the points and took about 5 to 9 ms more per frame in a release build (perf_tests harness, frame plus tessellation). Caching the flattened points alone would not have helped much, since the tessellation runs every frame anyway. The test checks how far the outline strays from the curve, which is what the tolerance controls. The sharpest turn per step depends on how large the curve is on screen, so a fixed angle was close to the edge. --- crates/ui-egui/src/canvas/outline.rs | 17 ++++- crates/ui-egui/src/canvas/outline_tests.rs | 79 ++++++++++++++++++++++ docs/ui-parity.md | 3 +- 3 files changed, 97 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/outline.rs b/crates/ui-egui/src/canvas/outline.rs index 37e7aebc2..1ef4b3b8b 100644 --- a/crates/ui-egui/src/canvas/outline.rs +++ b/crates/ui-egui/src/canvas/outline.rs @@ -170,14 +170,29 @@ pub(super) fn outline_path(doc: &Document, n: &figcraft_doc::Node) -> Option f64 { + (0.02 * curves as f64 / SMOOTH_CURVES as f64).clamp(0.02, 0.5) +} + +/// The most curved segments an outline flattens at the smooth 0.02 pt ([`outline_tolerance`]). +pub(super) const SMOOTH_CURVES: usize = 200; + /// [`outline_path`] on screen, flattened into polylines. fn outline_shape(app: &FigApp, doc: &Document, id: NodeId) -> Option>> { + use figcraft_geom::kurbo::PathEl; let n = doc.node(id)?; let path = outline_path(doc, n)?; let w = doc.world_transform(id); let mut out = Vec::new(); let mut cur: Vec = Vec::new(); - figcraft_geom::kurbo::flatten(path.iter(), 0.5 / app.session.ds().map(|d| d.view.zoom).unwrap_or(1.0), |el| { + let curves = path.elements().iter().filter(|el| matches!(el, PathEl::QuadTo(..) | PathEl::CurveTo(..))).count(); + let zoom = app.session.ds().map(|d| d.view.zoom).unwrap_or(1.0); + figcraft_geom::kurbo::flatten(path.iter(), outline_tolerance(curves) / zoom, |el| { use figcraft_geom::kurbo::PathEl::*; match el { MoveTo(p) => { diff --git a/crates/ui-egui/src/canvas/outline_tests.rs b/crates/ui-egui/src/canvas/outline_tests.rs index 115b83140..5f735051b 100644 --- a/crates/ui-egui/src/canvas/outline_tests.rs +++ b/crates/ui-egui/src/canvas/outline_tests.rs @@ -46,3 +46,82 @@ fn square_corners_keep_the_box() { let id = layer(&mut s, "rectangle", json!({"stroke": "#000000", "strokeWeight": 4, "strokeAlign": "outside"})); assert!(path_of(s.doc().unwrap(), id).is_none()); } + +/// How far, in screen points, layer `id`'s outline strays from its path: the largest distance from +/// the middle of one of its straight pieces to the path. +fn largest_stray(u: &crate::layers_drag_tests::Ui, id: NodeId) -> f64 { + use figcraft_geom::kurbo::ParamCurveNearest; + let doc = u.app.session.doc().unwrap().clone(); + let path = path_of(&doc, id).unwrap(); + let to_local = doc.world_transform(id).inverse(); + let zoom = u.app.session.ds().unwrap().view.zoom; + let mut largest: f64 = 0.0; + for shape in super::outline::outline_shapes(&u.app, &doc, id, egui::Stroke::new(1.0, egui::Color32::WHITE)) { + let egui::Shape::Path(line) = shape else { panic!("a polyline outline") }; + for piece in line.points.windows(2) { + let middle = to_local * u.app.to_page(piece[0] + (piece[1] - piece[0]) * 0.5); + let d = path.segments().map(|seg| seg.nearest(middle, 1e-9).distance_sq).fold(f64::MAX, f64::min).sqrt(); + largest = largest.max(d * zoom); + } + } + largest +} + +/// The outline is flattened to 0.02 pt on screen at any zoom, so its straight pieces don't show: +/// each stays well within 0.1 pt of the curve (0.5 pt left straight pieces visible on an ellipse). +#[test] +fn a_selected_ellipses_outline_stays_on_the_curve_at_any_zoom() { + let mut s = Session::new(); + let ellipse = + NodeId(s.execute("node.create", &json!({"type": "ellipse", "x": 0, "y": 0, "width": 65, "height": 50})).unwrap()["id"].as_u64().unwrap()); + let mut u = crate::layers_drag_tests::Ui::new(s); + for zoom in [1.0, 3.5, 16.0] { + u.app.session.execute("view.set", &json!({"zoom": zoom, "cx": 30, "cy": 25})).unwrap(); + u.frame(vec![]); + let stray = largest_stray(&u, ellipse); + assert!(stray < 0.1, "at {zoom}x the outline strays {stray:.3} pt from the curve"); + } +} + +/// A vector of `rows` closed bands, each `waves` cubic waves 10 pt wide along its top. +fn waves(rows: usize, waves: usize) -> String { + let mut d = String::new(); + for r in 0..rows { + let y = r as f64 * 10.0; + d += &format!("M0 {y} "); + for k in 0..waves { + let x = k as f64 * 10.0; + d += &format!("C{} {} {} {} {} {y} ", x + 3.3, y - 8.0, x + 6.6, y + 8.0, x + 10.0); + } + d += &format!("L{} {} L0 {} Z ", waves as f64 * 10.0, y + 6.0, y + 6.0); + } + d +} + +/// Heavy vectors are flattened coarser, so hovering, panning and zooming them stays as cheap as +/// before: a vector of 5,000 curves keeps the points 0.5 pt gave it (0.02 pt gives about five times +/// as many), and one of 200 still bends as smoothly as an ellipse. +#[test] +fn a_heavy_vectors_outline_keeps_the_points_it_had() { + use super::outline::{SMOOTH_CURVES, outline_shapes, outline_tolerance}; + let mut s = Session::new(); + let vector = |s: &mut Session, d: String| { + NodeId(s.execute("node.create", &json!({"type": "vector", "path": d, "closed": true, "x": 0, "y": 0})).unwrap()["id"].as_u64().unwrap()) + }; + let heavy = vector(&mut s, waves(50, 100)); + let light = vector(&mut s, waves(2, SMOOTH_CURVES / 2)); + let u = crate::layers_drag_tests::Ui::new(s); + let doc = u.app.session.doc().unwrap().clone(); + let points = |id: NodeId| -> usize { + outline_shapes(&u.app, &doc, id, egui::Stroke::new(1.0, egui::Color32::WHITE)) + .iter() + .map(|shape| if let egui::Shape::Path(line) = shape { line.points.len() } else { 0 }) + .sum() + }; + let zoom = u.app.session.ds().unwrap().view.zoom; + let mut before = 0; + figcraft_geom::kurbo::flatten(path_of(&doc, heavy).unwrap().iter(), 0.5 / zoom, |_| before += 1); + assert!(points(heavy) <= before, "{} points, {before} at 0.5 pt", points(heavy)); + assert_eq!(outline_tolerance(SMOOTH_CURVES), 0.02); + assert!(largest_stray(&u, light) < 0.1, "{SMOOTH_CURVES} curves bend smoothly"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..8164ec306 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (the hover and selection outline of a curved layer bends smoothly instead of showing straight pieces; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -219,6 +219,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | 2026-11-19 | patch | M5, #2360: with a frame selected, a drag that starts on one of its children moves the frame and a click selects the child (a press on a layer inside a selected one drags the selection), as in Figma; Cmd/Ctrl, Shift and layers outside the frame are unchanged. | | 2026-11-18 | patch | M5, #2372: the arrow keys move a layer along the canvas axes inside a rotated parent (the step was applied along the parent's axes, so Down moved a child of a frame rotated 90 degrees sideways); auto layout children are unchanged | | 2026-11-18 | patch | M1, #2355: Cmd/Ctrl+V with one layer inside a frame selected pasted the copy onto the page on top of the frame; it now goes into the layer's parent just above it (in an auto layout frame, the item after it, so the layout grows), keeping today's behaviour for a page-level layer, several layers, an instance's children and a board atom. Tests: `paste_sibling_tests` (5) | +| 2026-11-18 | patch | M1, #1506 follow-up: the hover and selection outline of an ellipse, a vector or a rounded corner was flattened into lines up to 0.5 pt from the curve on screen, so it turned up to 22° at a time on a 65 by 50 ellipse at 100% and showed straight pieces around it. It is now flattened to 0.02 pt at any zoom, so it stays within 0.1 pt of the curve. A path with more than 200 curves is flattened coarser as the count grows, up to the old 0.5 pt at 5,000: the outline is flattened again each frame the view moves or the layer is hovered and every point is tessellated each frame, and at 0.02 pt a vector of 5,000 curves took about 5 to 9 ms more per frame in a release build. Tests: `outline_tests::a_selected_ellipses_outline_stays_on_the_curve_at_any_zoom`, `outline_tests::a_heavy_vectors_outline_keeps_the_points_it_had` | | 2026-11-08 | minor | M8, #2109: in vector edit mode the Align commands (`align.left` to `align.bottom`, Alt+A/H/D/W/V/S) and Distribute horizontal and vertical spacing act on the selected points when neither `ids` nor `id` is given (either one targets layers), as in Figma (measured in Figma on 2026-11-08): each point moves along one axis only, to its box's left, horizontal centre, right, top, vertical centre or bottom, and distribute spaces the points evenly between the outermost two in order along the axis; handles go with their vertex, a single point stays, with no point selected nothing moves (the layer is not aligned to its frame, as measured in Figma), and one undo restores them. The Design panel draws the alignment row first, with a Distribute menu from three points. Numbers unchanged. | | 2026-11-08 | patch | Number fields: scrubbing a label moves half a step a point, not a step, as measured in Figma (X from 100: +6 for a 12.2 px drag, +31 for 61.2 px; rotation 6° and opacity 5% for 12.2 px); Shift (x10), Alt (x0.1) and the speed by height are kept on top of it and were not measured, and no field's scrub direction changed | | 2026-11-17 | patch | M8: each page keeps its view in a session: going back to a page (the Pages list, `page.select`, Previous/Next page) shows it where it was left instead of fitting it again; a new page is still fitted, and going to the page shown moves nothing (`page_view_tests`) | From 435d85b8a448503564de712dbaac3d79338314ea Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Wed, 18 Nov 2026 18:55:15 -0500 Subject: [PATCH 14/36] M1: Crop mode crops by the layer's sides in auto layout, up to the image, and never runs with vector edit In crop mode (Object > Crop image) the layer's sides and corners crop its image through the Cmd/Ctrl resize: the canvas sends Cmd/Ctrl while crop mode is on. Several things went wrong around that. Auto layout. The Cmd/Ctrl crop left out any layer with auto layout on it or an ancestor (#703), because the layout could recompute the box after the drag and a crop worked out for the dragged size would stretch. An image in an auto layout column was resized and squashed instead. The exclusion is gone: the crop is worked out for the dragged box in the preview and, once the layout has run, again from the snapshot for the size it left (crop_to_the_laid_out_box). A resize already makes the dragged axes Fixed; the layout may still move the layer, and the picture moves with it, unstretched. Where the layout makes the layer longer than it was dragged (a minimum width after the left side was dragged in), the crop slides back along the image rather than past its edge. Past the image. A side could be dragged beyond the image's edge, leaving an empty strip inside the layer. While the box isn't flipped, its sides now stop at the image's box (or where they started, if that was further out: a Fit image is smaller than its layer). The box is drawn back towards where it started, both ends of an axis by the same fraction, so an Alt resize stays centred, and with Shift both axes by the same fraction, so the ratio holds. A drag past the opposite side still flips as any resize does (command_crop_keeps_image_placement_in_the_layers_axes pins that). Ratio. A layer whose proportions are locked kept its ratio in crop mode too, so dragging a side moved the opposite axis; the crop window now ignores the lock and Shift keeps the ratio. The image's own corner handles were the other way round from a resize: in proportion by default, free with Shift. They now scale freely, in proportion with Shift. Vector edit. A double-click on the image enters vector edit mode, and Object > Crop image could be chosen while vector edit was on, so both ran at once. The injected Cmd/Ctrl then turned a drag of the layer's side into the Bend tool (a curved edge), and a dragged top segment showed the selected points' box, "804 x 0". Now image.crop ends vector edit, crop mode ends when vector edit starts, the canvas injects Cmd/Ctrl only while no points are being edited, and a double- or triple-click in crop mode stays in crop mode. When the second press of that double-click began a resize on a side of the layer, its release ends the resize. command_resize_leaves_fills_when_text_or_auto_layout_recomputes_the_box pinned the auto layout exclusion; its text case stays as command_resize_leaves_a_texts_fills. --- crates/engine/src/canvas/tools/drag.rs | 197 ++++++++++++++---- crates/engine/src/cmd/image.rs | 3 + .../engine/src/transform_behaviour_tests.rs | 147 +++++++++++-- crates/ui-egui/src/canvas.rs | 5 +- crates/ui-egui/src/canvas/handles.rs | 11 +- crates/ui-egui/src/canvas/input.rs | 15 ++ crates/ui-egui/src/crop_image_tests.rs | 129 ++++++++++++ docs/ui-parity.md | 3 +- 8 files changed, 445 insertions(+), 65 deletions(-) diff --git a/crates/engine/src/canvas/tools/drag.rs b/crates/engine/src/canvas/tools/drag.rs index 84ca02ba4..af183a2bd 100644 --- a/crates/engine/src/canvas/tools/drag.rs +++ b/crates/engine/src/canvas/tools/drag.rs @@ -557,9 +557,16 @@ impl Session { self.tool.overlay.guides = guides; return Ok(()); } - // Constrain proportions (Shift, or the node's lock). - let keep = ev.shift || r.single && ids.first().and_then(|i| self.doc().ok()?.node(*i).map(|n| n.constrain_proportions)).unwrap_or(false); - let (x0, y0, x1, y1) = resized_box(r.handle, q, w0, h0, keep, ev.alt); + let image_box = ids.first().filter(|_| ev.cmd && r.single).and_then(|i| self.image_box(*i)); + // Constrain proportions (Shift, or the node's lock; cropping an image ignores the lock). + let locked = + r.single && image_box.is_none() && ids.first().and_then(|i| self.doc().ok()?.node(*i).map(|n| n.constrain_proportions)).unwrap_or(false); + let keep = ev.shift || locked; + let resized = resized_box(r.handle, q, w0, h0, keep, ev.alt); + let (x0, y0, x1, y1) = match image_box { + Some(image) => within_the_image(resized, image, (w0, h0), keep), + None => resized, + }; let (flip_x, flip_y) = (x1 < x0, y1 < y0); let (nx0, ny0) = (x0.min(x1), y0.min(y1)); let (nw, nh) = ((x1 - x0).abs(), (y1 - y0).abs()); @@ -571,46 +578,30 @@ impl Session { let keeps = |doc: &Document, id: NodeId| { doc.node(id).is_some_and(|n| matches!(n.kind, NodeKind::Section { .. }) || (ev.cmd && single && n.kind.is_frame_like())) }; + let dragged_box = |world: Affine, (ox, oy): (f64, f64)| { + let mut t = world * Affine::translate((ox, oy)); + if flip_x { + t *= Affine::new([-1.0, 0.0, 0.0, 1.0, nw, 0.0]); + } + if flip_y { + t *= Affine::new([1.0, 0.0, 0.0, -1.0, 0.0, nh]); + } + t + }; self.preview(|doc, _| { if single { let Some((id, world, _, _)) = nodes.first() else { return Ok(()) }; let kept = if keeps(doc, *id) { crate::cmd::props::children_worlds(doc, *id) } else { Vec::new() }; - let mut t = *world * Affine::translate((nx0, ny0)); - if flip_x { - t *= Affine::new([-1.0, 0.0, 0.0, 1.0, nw, 0.0]); - } - if flip_y { - t *= Affine::new([1.0, 0.0, 0.0, -1.0, 0.0, nh]); - } + let t = dragged_box(*world, (nx0, ny0)); // Text reflow and auto layout can recompute this box after the preview (a size bound - // to a variable lets go of it: the resize is an explicit edit). + // to a variable lets go of it: the resize is an explicit edit). A text keeps its + // fills; any other layer's image is cropped again for the box layout leaves + // (`crop_to_the_laid_out_box`). let n = doc.get(*id)?; - let crop_images = ev.cmd - && !matches!(n.kind, NodeKind::Text(_)) - && !std::iter::once(*id).chain(doc.ancestors(*id)).any(|a| doc.node(a).is_some_and(|n| n.layout.is_some())); - if crop_images { - // Crop the layer's image fills without moving their pixels on the page. - // Work from the interaction snapshot, just like the geometry on every move. - let (w, h) = (n.width.max(1e-6), n.height.max(1e-6)); - let to_old = - Affine::scale_non_uniform(1.0 / w, 1.0 / h) * world.inverse() * t * Affine::scale_non_uniform(nw.max(0.01), nh.max(0.01)); - let mut fills = n.fills.clone(); - for paint in &mut fills { - let PaintKind::Image(img) = &mut paint.kind else { continue }; - // A repeating image cannot be represented by a single Crop placement. - if img.scale_mode == ImageScaleMode::Tile { - continue; - } - let Some(data) = doc.images.get(&img.image) else { continue }; - let (iw, ih) = (f64::from(data.width), f64::from(data.height)); - // A degenerate (zero-scale) layer has no inverse: its image keeps its placement. - let crop = (Affine::new(img.placement_crop(iw, ih, w, h)) * to_old).as_coeffs(); - if !crop.iter().all(|c| c.is_finite()) { - continue; - } - img.crop = Some(crop); - img.scale_mode = ImageScaleMode::Crop; - } + // Crop the layer's image fills without moving their pixels on the page. + // Work from the interaction snapshot, just like the geometry on every move. + if ev.cmd && !matches!(n.kind, NodeKind::Text(_)) { + let fills = cropped_image_fills(doc, n, *world, t, (nw, nh)); doc.get_mut(*id)?.fills = fills; } doc.set_world_transform(*id, t)?; @@ -656,10 +647,67 @@ impl Session { } Ok(()) })?; + if single + && ev.cmd + && let Some((id, world, _, _)) = nodes.first() + { + let laid_out_box = |(fw, fh): (f64, f64)| { + let origin = match image_box { + Some((ix0, iy0, ix1, iy1)) => { + (slid_onto_the_image(nx0, fw, flip_x, (ix0, ix1), w0), slid_onto_the_image(ny0, fh, flip_y, (iy0, iy1), h0)) + } + None => (nx0, ny0), + }; + dragged_box(*world, origin) + }; + self.crop_to_the_laid_out_box(*id, *world, laid_out_box, (nw, nh))?; + } self.tool.overlay.guides = guides; Ok(()) } + /// The box `(x0, y0, x1, y1)` of the first visible, untiled image fill of `id` in the layer's + /// own axes, as it was when the gesture began; `None` for a text or a layer without one. + fn image_box(&self, id: NodeId) -> Option<(f64, f64, f64, f64)> { + let snapshot = self.ds().ok()?.interaction.as_ref()?.doc.clone(); + let n = snapshot.node(id)?; + if matches!(n.kind, NodeKind::Text(_)) { + return None; + } + n.fills.iter().filter(|p| p.visible).find_map(|p| match &p.kind { + PaintKind::Image(img) if img.scale_mode != ImageScaleMode::Tile => { + let data = snapshot.images.get(&img.image)?; + let crop = img.effective_crop(f64::from(data.width), f64::from(data.height), n.width, n.height); + let (x0, y0, x1, y1) = figcraft_doc::color::ImagePaint::crop_rect(crop); + Some((x0 * n.width, y0 * n.height, x1 * n.width, y1 * n.height)) + } + _ => None, + }) + } + + /// After the preview's layout: when the layer didn't keep the dragged size `(nw, nh)` (a + /// minimum size, a Hug frame), crop its image fills again from the snapshot for the size it + /// has, the box placed by `laid_out_box` (given that size) in the layer's starting axes. + fn crop_to_the_laid_out_box( + &mut self, + id: NodeId, + world: Affine, + laid_out_box: impl Fn((f64, f64)) -> Affine, + (nw, nh): (f64, f64), + ) -> Result<()> { + let ds = self.ds_mut()?; + let Some(snapshot) = ds.interaction.as_ref().map(|it| it.doc.clone()) else { return Ok(()) }; + let Some(before) = snapshot.node(id).filter(|n| !matches!(n.kind, NodeKind::Text(_))) else { return Ok(()) }; + let Some((fw, fh)) = ds.doc.node(id).map(|n| (n.width, n.height)) else { return Ok(()) }; + if (fw - nw.max(0.01)).abs() < 1e-9 && (fh - nh.max(0.01)).abs() < 1e-9 { + return Ok(()); + } + let fills = cropped_image_fills(&snapshot, before, world, laid_out_box((fw, fh)), (fw, fh)); + std::sync::Arc::make_mut(&mut ds.doc).get_mut(id)?.fills = fills; + ds.revision += 1; + Ok(()) + } + /// Scale tool handle drag (`q`: the snapped pointer in the handle box's axes): everything /// scales by one factor about the anchor point (Alt: the centre), strokes, effects, radii and /// text included, children by the same factor whatever their constraints. @@ -703,3 +751,78 @@ fn only_shifted(doc: &Document, moving: &[NodeId]) -> bool { !in_flow && !nested }) } + +/// `before`'s fills (from the snapshot `doc`) with each image cropped to the box `dragged` (the +/// layer's new transform, `nw` × `nh`), its pixels left where they were on the page (`world`: +/// the layer's transform before the drag). +fn cropped_image_fills( + doc: &Document, + before: &figcraft_doc::Node, + world: Affine, + dragged: Affine, + (nw, nh): (f64, f64), +) -> Vec { + let (w, h) = (before.width.max(1e-6), before.height.max(1e-6)); + let to_before = Affine::scale_non_uniform(1.0 / w, 1.0 / h) * world.inverse() * dragged * Affine::scale_non_uniform(nw.max(0.01), nh.max(0.01)); + let mut fills = before.fills.clone(); + for paint in &mut fills { + let PaintKind::Image(img) = &mut paint.kind else { continue }; + // A repeating image cannot be represented by a single Crop placement. + if img.scale_mode == ImageScaleMode::Tile { + continue; + } + let Some(data) = doc.images.get(&img.image) else { continue }; + let (iw, ih) = (f64::from(data.width), f64::from(data.height)); + // A degenerate (zero-scale) layer has no inverse: its image keeps its placement. + let crop = (Affine::new(img.placement_crop(iw, ih, w, h)) * to_before).as_coeffs(); + if !crop.iter().all(|c| c.is_finite()) { + continue; + } + img.crop = Some(crop); + img.scale_mode = ImageScaleMode::Crop; + } + fills +} + +/// The extent `lo..hi` an image of extent `image` lets a crop reach on one axis of a layer that +/// started `len` long: the image's, or the layer's where that reaches further (a Fit image is +/// smaller than its layer). +fn crop_reach(image: (f64, f64), len: f64) -> (f64, f64) { + (image.0.min(image.1).min(0.0), image.0.max(image.1).max(len)) +} + +/// The dragged box `(x0, y0, x1, y1)` drawn back towards the starting box `(0, 0, w0, h0)` until +/// its sides stop at the image's box `image` (see [`crop_reach`]). Both ends of an axis go back by +/// the same fraction, so an Alt resize stays centred, and with `keep` (Shift) both axes do, so the +/// ratio holds. A flipped axis stays as dragged. +fn within_the_image((x0, y0, x1, y1): (f64, f64, f64, f64), image: (f64, f64, f64, f64), (w0, h0): (f64, f64), keep: bool) -> (f64, f64, f64, f64) { + let fraction = |a: f64, b: f64, image: (f64, f64), len: f64| { + if b < a { + return 1.0; + } + let (lo, hi) = crop_reach(image, len); + let mut t: f64 = 1.0; + if a < lo { + t = t.min(lo / a); + } + if b > hi { + t = t.min((hi - len) / (b - len)); + } + if t.is_finite() { t.clamp(0.0, 1.0) } else { 0.0 } + }; + let (tx, ty) = (fraction(x0, x1, (image.0, image.2), w0), fraction(y0, y1, (image.1, image.3), h0)); + let (tx, ty) = if keep { (tx.min(ty), tx.min(ty)) } else { (tx, ty) }; + (x0 * tx, y0 * ty, w0 + (x1 - w0) * tx, h0 + (y1 - h0) * ty) +} + +/// Where a crop box `len` long, placed at `start` on one axis, starts once it is slid back onto +/// the image (see [`crop_reach`]): layout can make a layer longer than it was dragged (a minimum +/// size), and the crop then moves along the image rather than past its edge. A flipped axis, or +/// a box longer than the reach, stays where it is. +fn slid_onto_the_image(start: f64, len: f64, flipped: bool, image: (f64, f64), len0: f64) -> f64 { + let (lo, hi) = crop_reach(image, len0); + if flipped || len.is_nan() || len > hi - lo { + return start; + } + start.max(lo).min(hi - len) +} diff --git a/crates/engine/src/cmd/image.rs b/crates/engine/src/cmd/image.rs index 37472b2d4..123f47ed8 100644 --- a/crates/engine/src/cmd/image.rs +++ b/crates/engine/src/cmd/image.rs @@ -222,6 +222,9 @@ fn crop(s: &mut Session, p: &Value) -> Result { // Like any paint edit, the layer leaves its paint style. n.styles.fill = None; } + if s.ds()?.vector_edit.is_some() { + crate::vectoredit::end(s)?; + } s.request_ui(cmd, json!({"id": id, "index": index})); Ok(json!({"id": id, "index": index})) } diff --git a/crates/engine/src/transform_behaviour_tests.rs b/crates/engine/src/transform_behaviour_tests.rs index 3c37bf6c0..01773c70f 100644 --- a/crates/engine/src/transform_behaviour_tests.rs +++ b/crates/engine/src/transform_behaviour_tests.rs @@ -242,43 +242,134 @@ fn command_crop_preserves_each_image_fill_and_leaves_tiles() { } #[test] -fn command_resize_leaves_fills_when_text_or_auto_layout_recomputes_the_box() { - for case in ["text", "child", "frame"] { +fn command_resize_leaves_a_texts_fills() { + let mut s = session(); + let image = image_layer(&mut s); + let fills = s.doc().unwrap().node(image).unwrap().fills.clone(); + let layer = id(&ex( + &mut s, + "text.create", + json!({"text": "hello world hello world hello world", "props": { + "width": 200, "height": 100, "fontSize": 24, "textAutoResize": "none", "fills": fills + }}), + )); + ex(&mut s, "select.set", json!({"ids": [layer]})); + let doc = s.doc().unwrap(); + let world = doc.world_transform(layer); + let n = doc.node(layer).unwrap(); + let (from, to) = (world * Point::new(n.width, n.height / 2.0), world * Point::new(10.0, n.height / 2.0)); + drag(&mut s, from, to, CMD); + assert_eq!(s.doc().unwrap().node(layer).unwrap().fills, fills, "a text reflows: keep the existing resize behaviour"); +} + +fn image_units_per_layer_unit(s: &Session, layer: NodeId) -> (f64, f64, f64, f64) { + use figcraft_doc::color::PaintKind; + let doc = s.doc().unwrap(); + let n = doc.node(layer).unwrap(); + let PaintKind::Image(img) = &n.fills[0].kind else { panic!("image fill") }; + let data = doc.images.get(&img.image).unwrap(); + let c = img.effective_crop(f64::from(data.width), f64::from(data.height), n.width, n.height); + (c[0] / n.width, c[3] / n.height, c[4], c[5]) +} + +#[test] +fn command_resize_crops_in_auto_layout_against_the_box_layout_leaves() { + use figcraft_doc::color::{ImageScaleMode, PaintKind}; + for case in ["child", "child with a minimum width", "auto layout frame"] { let mut s = session(); let image = image_layer(&mut s); let fills = s.doc().unwrap().node(image).unwrap().fills.clone(); - let layer = match case { - "text" => id(&ex( - &mut s, - "text.create", - json!({"text": "hello world hello world hello world", "props": { - "width": 200, "height": 100, "fontSize": 24, "textAutoResize": "none", "fills": fills - }}), - )), + let frame = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 240, "height": 140}))); + set(&mut s, &[frame], json!({"layout": "horizontal", "padding": 20})); + let (layer, to_x, width) = match case { + "auto layout frame" => { + set(&mut s, &[frame], json!({"fills": fills})); + (frame, 10.0, 40.0) + } _ => { - let frame = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 200, "height": 100}))); - set(&mut s, &[frame], json!({"layout": "horizontal", "padding": 20})); + ex(&mut s, "node.reparent", json!({"ids": [image], "parent": frame})); if case == "child" { - ex(&mut s, "node.reparent", json!({"ids": [image], "parent": frame})); - set(&mut s, &[image], json!({"minWidth": 150})); - image + (image, 150.0, 150.0) } else { - set(&mut s, &[frame], json!({"fills": fills})); - frame + set(&mut s, &[image], json!({"minWidth": 150})); + (image, 10.0, 150.0) } } }; ex(&mut s, "select.set", json!({"ids": [layer]})); + let before = image_units_per_layer_unit(&s, layer); let doc = s.doc().unwrap(); let world = doc.world_transform(layer); let n = doc.node(layer).unwrap(); - let from = world * Point::new(n.width, n.height / 2.0); - let to = world * Point::new(10.0, n.height / 2.0); + let (from, to) = (world * Point::new(n.width, n.height / 2.0), world * Point::new(to_x, n.height / 2.0)); drag(&mut s, from, to, CMD); - assert_eq!(s.doc().unwrap().node(layer).unwrap().fills, fills, "{case}: keep the existing resize behaviour"); + let n = s.doc().unwrap().node(layer).unwrap().clone(); + assert!(near(n.width, width), "{case}: {} wide, as auto layout leaves it", n.width); + let PaintKind::Image(img) = &n.fills[0].kind else { panic!("image fill") }; + assert_eq!(img.scale_mode, ImageScaleMode::Crop, "{case}: cropped"); + let after = image_units_per_layer_unit(&s, layer); + assert!(near(after.0, before.0) && near(after.1, before.1), "{case}: the image keeps its scale, not stretched: {before:?} -> {after:?}"); + assert!(near(after.2, before.2) && near(after.3, before.3), "{case}: its left edge stays where it was in the layer: {before:?} -> {after:?}"); } } +/// A minimum width can give a layer back the width its left side was dragged in by: the crop then +/// slides back along the image instead of running past its right edge. +#[test] +fn command_crop_slides_back_onto_the_image_when_layout_widens_the_layer() { + use figcraft_doc::color::{ImagePaint, PaintKind}; + let mut s = session(); + let image = image_layer(&mut s); + let frame = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 240, "height": 140}))); + set(&mut s, &[frame], json!({"layout": "horizontal", "padding": 20})); + ex(&mut s, "node.reparent", json!({"ids": [image], "parent": frame})); + set(&mut s, &[image], json!({"minWidth": 150})); + ex(&mut s, "select.set", json!({"ids": [image]})); + let before = image_units_per_layer_unit(&s, image); + let world = s.doc().unwrap().world_transform(image); + drag(&mut s, world * Point::new(0.0, 50.0), world * Point::new(190.0, 50.0), CMD); + let doc = s.doc().unwrap(); + let n = doc.node(image).unwrap(); + assert!(near(n.width, 150.0), "{} wide, as the minimum width leaves it", n.width); + let PaintKind::Image(img) = &n.fills[0].kind else { panic!("image fill") }; + let data = doc.images.get(&img.image).unwrap(); + let crop = img.effective_crop(f64::from(data.width), f64::from(data.height), n.width, n.height); + let (x0, _, x1, _) = ImagePaint::crop_rect(crop); + assert!(x0 <= 1e-9 && x1 >= 1.0 - 1e-9, "the image covers the layer: {x0}..{x1}"); + let after = image_units_per_layer_unit(&s, image); + assert!(near(after.0, before.0) && near(after.1, before.1), "the image keeps its scale: {before:?} -> {after:?}"); +} + +/// Where the image's edge stops a crop, Shift still keeps the ratio (both axes stop together) and +/// Alt still keeps the box centred (both sides stop together). +#[test] +fn command_crop_stopped_by_the_image_keeps_the_ratio_with_shift_and_the_centre_with_alt() { + let mut s = session(); + let layer = image_layer(&mut s); + ex(&mut s, "select.set", json!({"ids": [layer]})); + drag(&mut s, Point::new(200.0, 100.0), Point::new(150.0, 80.0), CMD); + assert_eq!(size(&s, layer), (150.0, 80.0)); + drag(&mut s, Point::new(150.0, 80.0), Point::new(240.0, 128.0), Mods { shift: true, alt: false, cmd: true }); + assert!( + near_rect(bounds(&s, layer), Rect::new(0.0, 0.0, 187.5, 100.0)), + "the bottom stops at the image, the right side with it: {:?}", + bounds(&s, layer) + ); + + let mut s = session(); + let layer = image_layer(&mut s); + ex(&mut s, "select.set", json!({"ids": [layer]})); + drag(&mut s, Point::new(0.0, 50.0), Point::new(20.0, 50.0), CMD); + drag(&mut s, Point::new(200.0, 50.0), Point::new(150.0, 50.0), CMD); + assert!(near_rect(bounds(&s, layer), Rect::new(20.0, 0.0, 150.0, 100.0)), "{:?}", bounds(&s, layer)); + drag(&mut s, Point::new(150.0, 50.0), Point::new(190.0, 50.0), Mods { shift: false, alt: true, cmd: true }); + assert!( + near_rect(bounds(&s, layer), Rect::new(0.0, 0.0, 170.0, 100.0)), + "the left side stops at the image, the right side as far: {:?}", + bounds(&s, layer) + ); +} + /// A resize is an explicit edit of the size: a size bound to a variable lets go of it (#809), so /// Cmd/Ctrl crops a bound layer's image as any other's; other bindings stay. #[test] @@ -856,3 +947,19 @@ fn the_transform_box_and_its_handles() { // At a larger zoom the same layer is big enough on screen for its handles inside it. assert_eq!(handle_at(s.doc().unwrap(), &[tiny], Point::new(320.2, 10.2), 20.0), Some(Handle::Corner(0))); } + +#[test] +fn command_crop_changes_a_locked_ratio_and_stops_at_the_images_edges() { + let mut s = session(); + let layer = image_layer(&mut s); + set(&mut s, &[layer], json!({"constrainProportions": true})); + ex(&mut s, "select.set", json!({"ids": [layer]})); + drag(&mut s, Point::new(200.0, 50.0), Point::new(150.0, 50.0), CMD); + assert_eq!(size(&s, layer), (150.0, 100.0), "a side changes the ratio, lock or not"); + drag(&mut s, Point::new(150.0, 50.0), Point::new(260.0, 50.0), CMD); + assert_eq!(size(&s, layer), (200.0, 100.0), "the side stops at the image's edge"); + drag(&mut s, Point::new(100.0, 0.0), Point::new(100.0, -40.0), CMD); + assert!(near_rect(bounds(&s, layer), Rect::new(0.0, 0.0, 200.0, 100.0)), "the top stops at the image's top: {:?}", bounds(&s, layer)); + drag(&mut s, Point::new(200.0, 50.0), Point::new(100.0, 50.0), Mods { shift: true, alt: false, cmd: true }); + assert_eq!(size(&s, layer), (100.0, 50.0), "Shift keeps the ratio"); +} diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 3d3f05082..a05f9414c 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -234,8 +234,9 @@ fn pointer_event(app: &FigApp, kind: PointerKind, pos: Pos2, m: &egui::Modifiers sy: f64::from(pos.y), shift: m.shift, alt: m.alt, - // Crop mode: resizing the layer crops it, as Cmd/Ctrl-resizing does. - cmd: m.command || app.ui.crop.is_some(), + // Crop mode: resizing the layer crops it, as Cmd/Ctrl-resizing does (not while its points + // are being edited, where Cmd/Ctrl bends a segment). + cmd: m.command || (app.ui.crop.is_some() && app.session.ds().is_ok_and(|d| d.vector_edit.is_none())), ctrl: m.ctrl, zoom, pressure: app.canvas.pressure, diff --git a/crates/ui-egui/src/canvas/handles.rs b/crates/ui-egui/src/canvas/handles.rs index 0a300c279..a92cacabf 100644 --- a/crates/ui-egui/src/canvas/handles.rs +++ b/crates/ui-egui/src/canvas/handles.rs @@ -529,9 +529,10 @@ fn draw_crop(app: &FigApp, painter: &egui::Painter, id: NodeId, img: &ImagePaint /// Draw the handles. pub fn draw(app: &mut FigApp, painter: &egui::Painter) { - // Crop mode ends when a colour picker opens, or when its layer leaves the selection or its fill - // is no longer a Crop image (an undo). - if app.ui.crop.is_some() && (app.ui.picker.is_some() || crop_target(app).is_none()) { + // Crop mode ends when a colour picker opens, when its layer leaves the selection or its fill + // is no longer a Crop image (an undo), or when the layer's points are being edited. + let editing_points = app.session.ds().is_ok_and(|d| d.vector_edit.is_some()); + if app.ui.crop.is_some() && (app.ui.picker.is_some() || crop_target(app).is_none() || editing_points) { app.ui.crop = None; } let app = &*app; @@ -821,13 +822,13 @@ fn apply(app: &mut FigApp, drag: &Drag, pos: Pos2, modifiers: egui::Modifiers) { let (dx, dy) = (u.0 - start.0, u.1 - start.1); (x0 + dx, y0 + dy, x1 + dx, y1 + dy) } else { - // Scale about the opposite corner, keeping the image's aspect ratio unless Shift. + // Scale about the opposite corner, keeping the image's aspect ratio with Shift. let corners = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]; let (ax, ay) = corners.get((*which + 2) % 4).copied().unwrap_or((x0, y0)); let (cx, cy) = corners.get(*which).copied().unwrap_or((x1, y1)); let (ow, oh) = (cx - ax, cy - ay); let (mut nw, mut nh) = (u.0 - ax, u.1 - ay); - if !modifiers.shift { + if modifiers.shift { // Node aspect matters: the unit box is not square in pixels. let Some(n) = app.session.doc().ok().and_then(|d| d.node(*id)).cloned() else { return }; let k = ((nw * n.width).abs() / (ow * n.width).abs().max(1e-9)).max((nh * n.height).abs() / (oh * n.height).abs().max(1e-9)); diff --git a/crates/ui-egui/src/canvas/input.rs b/crates/ui-egui/src/canvas/input.rs index 6ecdb948c..1a8dcd1a9 100644 --- a/crates/ui-egui/src/canvas/input.rs +++ b/crates/ui-egui/src/canvas/input.rs @@ -297,6 +297,9 @@ pub(super) fn input(app: &mut FigApp, ui: &mut Ui, resp: &egui::Response) -> boo open_context_menu(app, pos, mods.command); return true; } + if crop_mode_multi_click(app, resp, pos, &mods) { + return true; + } // A third quick click is counted as a triple, not a double (a click elsewhere in between still // leaves its time in the sequence): it means the same here — edit, enter, open — unless a // vector or text is being edited, where a triple already has its own meaning. A triple on @@ -414,6 +417,18 @@ fn pan_past_edge(app: &mut FigApp, ctx: &egui::Context, mods: &egui::Modifiers) } } +/// A double- or triple-click in crop mode stays in crop mode (it would edit the points), and is +/// taken here. Its last press may have begun a resize on a side of the layer: its release ends that. +fn crop_mode_multi_click(app: &mut FigApp, resp: &egui::Response, pos: Pos2, mods: &egui::Modifiers) -> bool { + if app.ui.crop.is_none() || !(resp.double_clicked() || resp.triple_clicked()) { + return false; + } + if std::mem::take(&mut app.canvas.dragging) { + send(app, PointerKind::Up, pos, mods); + } + true +} + fn send(app: &mut FigApp, kind: PointerKind, pos: Pos2, m: &egui::Modifiers) { let ev = pointer_event(app, kind, pos, m); // A hover where nothing changed since the last one finds what that one found (the state is diff --git a/crates/ui-egui/src/crop_image_tests.rs b/crates/ui-egui/src/crop_image_tests.rs index 05435d856..8db0094d2 100644 --- a/crates/ui-egui/src/crop_image_tests.rs +++ b/crates/ui-egui/src/crop_image_tests.rs @@ -322,3 +322,132 @@ fn crop_in_the_colour_picker_only_sets_the_mode_where_crop_image_does_not_apply( assert_eq!(crop_on_canvas(&u.app, &PickerTarget::PageBackground), None); assert_eq!(crop_on_canvas(&u.app, &PickerTarget::Style { id: "S:1".into(), index: 0 }), None); } + +#[test] +fn in_crop_mode_the_edges_of_an_image_in_auto_layout_crop_it_too() { + let (mut u, layer, _) = setup(); + let column = id(&u.app.session.execute("frame.create", &json!({"x": 0, "y": 0, "width": 200, "height": 100})).unwrap()); + u.app.run("node.reparent", json!({"ids": [layer], "parent": column})); + u.app.run("node.set", json!({"ids": [column], "props": {"layout": "vertical", "sizingV": "hug"}})); + u.app.run("select.set", json!({"ids": [layer]})); + u.app.run("image.crop", json!({})); + u.frame(vec![]); + let (_, Some(before)) = mode(&u, layer) else { panic!("a crop") }; + let (from, to) = (u.app.to_screen(100.0, 100.0), u.app.to_screen(100.0, 60.0)); + u.drag_to(from, to); + u.button(to, false); + let n = u.app.session.doc().unwrap().node(layer).unwrap().clone(); + assert!((n.height - 60.0).abs() < 1e-6 && (n.width - 200.0).abs() < 1e-6, "the bottom edge moved up: {} x {}", n.width, n.height); + let (m, Some(after)) = mode(&u, layer) else { panic!("a crop") }; + assert_eq!(m, ImageScaleMode::Crop); + assert!((after[3] - before[3] * 0.6).abs() < 1e-9 && (after[0] - before[0]).abs() < 1e-9, "cropped, not squashed: {before:?} -> {after:?}"); + assert!((after[5] - before[5]).abs() < 1e-9, "the top stays: {before:?} -> {after:?}"); + assert_eq!(u.app.ui.crop, Some((layer, 0)), "still cropping"); +} + +#[test] +fn a_double_click_in_crop_mode_keeps_cropping_and_vector_edit_ends_crop_mode() { + let (mut u, layer, _) = setup(); + u.app.run("image.crop", json!({})); + u.frame(vec![]); + let at = u.app.to_screen(100.0, 50.0); + for _ in 0..2 { + u.button(at, true); + u.button(at, false); + } + u.frame(vec![]); + assert!(u.app.session.ds().unwrap().vector_edit.is_none(), "a double-click while cropping doesn't edit the points"); + assert_eq!(u.app.ui.crop, Some((layer, 0)), "still cropping"); + let (from, to) = (u.app.to_screen(200.0, 50.0), u.app.to_screen(150.0, 50.0)); + u.drag_to(from, to); + u.button(to, false); + let n = u.app.session.doc().unwrap().node(layer).unwrap().clone(); + assert!((n.width - 150.0).abs() < 1e-6 && matches!(n.kind, figcraft_doc::NodeKind::Rectangle), "the side crops; the layer stays a rectangle"); + u.app.run("vector.edit.begin", json!({"id": layer})); + u.frame(vec![]); + assert_eq!(u.app.ui.crop, None, "editing the points ends crop mode"); + u.app.run("image.crop", json!({})); + u.frame(vec![]); + assert!(u.app.session.ds().unwrap().vector_edit.is_none(), "cropping ends editing the points"); + assert_eq!(u.app.ui.crop, Some((layer, 0))); +} + +/// The second press of a double-click on a side of the layer begins a resize; its release, which +/// is the double-click, ends it, and crop mode stays. +#[test] +fn a_double_click_on_a_side_in_crop_mode_leaves_no_resize_open() { + let (mut u, layer, _) = setup(); + u.app.run("image.crop", json!({})); + u.frame(vec![]); + let at = u.app.to_screen(200.0, 50.0); + for _ in 0..2 { + u.button(at, true); + u.button(at, false); + } + u.frame(vec![]); + assert!(u.app.session.ds().unwrap().interaction.is_none(), "the resize the second press began is over"); + assert_eq!(u.app.ui.crop, Some((layer, 0)), "still cropping"); +} + +#[test] +fn in_crop_mode_the_images_corners_scale_freely_and_with_shift_in_proportion() { + let image_size = |u: &Ui, layer: NodeId| { + let n = u.app.session.doc().unwrap().node(layer).unwrap().clone(); + let (_, Some(c)) = mode(u, layer) else { panic!("a crop") }; + let (x0, y0, x1, y1) = figcraft_color::ImagePaint::crop_rect(c); + ((x1 - x0) * n.width, (y1 - y0) * n.height) + }; + for shift in [false, true] { + let (mut u, layer, _) = setup(); + u.app.run("image.crop", json!({})); + u.frame(vec![]); + let (from, to) = (u.app.to_screen(200.0, 50.0), u.app.to_screen(150.0, 50.0)); + u.drag_to(from, to); + u.button(to, false); + let (w0, h0) = image_size(&u, layer); + let modifiers = if shift { Modifiers::SHIFT } else { Modifiers::NONE }; + let (from, to) = (u.app.to_screen(200.0, 100.0), u.app.to_screen(260.0, 110.0)); + u.frame_with( + vec![Event::PointerMoved(from), Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed: true, modifiers }], + modifiers, + ); + for k in 1..=10 { + u.frame_with(vec![Event::PointerMoved(from + (to - from) * (k as f32 / 10.0))], modifiers); + } + u.frame_with(vec![Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers }], modifiers); + let (w1, h1) = image_size(&u, layer); + let kept = (w1 / h1 - w0 / h0).abs() < 1e-6; + assert!(w1 > w0, "the corner scaled the image: {w0}x{h0} -> {w1}x{h1}"); + assert_eq!(kept, shift, "Shift {shift}: {w0}x{h0} -> {w1}x{h1}"); + } +} + +#[test] +fn in_auto_layout_a_side_dragged_past_the_image_leaves_no_empty_strip() { + let mut s = Session::new(); + let image = image::RgbaImage::from_fn(300, 200, |x, y| image::Rgba([(x % 255) as u8, (y % 255) as u8, 120, 255])); + let mut png = std::io::Cursor::new(Vec::new()); + image.write_to(&mut png, image::ImageFormat::Png).unwrap(); + let data = base64::engine::general_purpose::STANDARD.encode(png.into_inner()); + let content = id(&s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 1092, "height": 1400})).unwrap()); + id(&s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 300, "height": 160, "parent": content})).unwrap()); + let layer = id(&s.execute("image.place", &json!({"data": data, "x": 0, "y": 300, "width": 804, "height": 969})).unwrap()); + s.execute("node.reparent", &json!({"ids": [layer], "parent": content})).unwrap(); + s.execute("node.set", &json!({"ids": [content], "props": {"layout": "vertical", "sizingV": "hug", "padding": [112, 0, 100, 0]}})).unwrap(); + s.execute("node.set", &json!({"ids": [layer], "props": {"constrainProportions": true}})).unwrap(); + s.execute("select.set", &json!({"ids": [layer]})).unwrap(); + let mut u = Ui::new(s); + u.app.run("view.set", json!({"zoom": 0.5, "cx": 546, "cy": 700})); + u.app.run("image.crop", json!({})); + u.frame(vec![]); + let b = u.app.session.doc().unwrap().world_bounds(layer).unwrap(); + let (from, to) = (u.app.to_screen(400.0, b.y0), u.app.to_screen(400.0, b.y0 - 120.0)); + u.drag_to(from, to); + u.button(to, false); + let n = u.app.session.doc().unwrap().node(layer).unwrap().clone(); + let (_, Some(c)) = mode(&u, layer) else { panic!("a crop") }; + let (x0, y0, x1, y1) = figcraft_color::ImagePaint::crop_rect(c); + assert!(x0 <= 1e-9 && y0 <= 1e-9 && x1 >= 1.0 - 1e-9 && y1 >= 1.0 - 1e-9, "the image covers the layer: {:?}", (x0, y0, x1, y1)); + assert!(n.width >= 1.0 && n.height >= 1.0, "{} x {}", n.width, n.height); + assert!(u.app.session.ds().unwrap().vector_edit.is_none()); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..c7b6e4a07 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (crop mode: the layer's sides and corners crop its image in an auto layout frame too, up to the image's edges, change a locked ratio (Shift keeps it), the image's own corners scale freely with Shift proportional as a resize does, and crop mode and vector edit mode end each other; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-18 | patch | M1, crop mode (Object ▸ Crop image, #1464): the layer's sides and corners (the Cmd/Ctrl resize crop) crop its image in an auto layout frame too, against the box the layout leaves, instead of squashing the picture; a side can go no further than the image's edge, so no empty strip opens inside the layer (Shift still keeps the ratio and Alt the centre there, and a crop the layout widens slides back along the image); a locked ratio doesn't hold the crop window and Shift keeps its ratio; the image's own corner handles scale it freely and in proportion with Shift, as a resize does (they were the other way round). Crop mode and vector edit mode end each other, and a double-click in crop mode stays in it: with both on, the injected Cmd/Ctrl turned a drag of the layer's side into the Bend tool and showed the selected points' box ("804 × 0"). Tests: `crop_image_tests` (5 new), `transform_behaviour_tests::command_crop_changes_a_locked_ratio_and_stops_at_the_images_edges`, `command_crop_stopped_by_the_image_keeps_the_ratio_with_shift_and_the_centre_with_alt`, `command_crop_slides_back_onto_the_image_when_layout_widens_the_layer`, `command_resize_crops_in_auto_layout_against_the_box_layout_leaves` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 782b2ea3694e717395045fcf60f3c10c4cb4ad00 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:57:49 -0500 Subject: [PATCH 15/36] M4: Tab while editing a text layer goes on to the next text layer Tab while editing a text layer typed a tab character, and Shift+Tab did too, so filling in a form built from instances took a double-click into every label. Tab now ends editing the text and edits the next text layer with all of its text selected; Shift+Tab goes to the previous one. The order is reading order: rows top to bottom, each left to right; two layers share a row when they overlap vertically by at least half the shorter one's height. The candidates are the text layers of the same top-level frame or group, at any depth and inside instances, that are visible and unlocked along with every layer around them; a text on the page or in a section goes to the texts beside it. At the last text Tab does nothing, and Shift+Tab at the first. Tab keeps nesting a list item, typing two spaces in a code block and typing a tab in a board object's text or a widget's field. The view doesn't follow a text that is off screen: nothing in the app scrolls a layer into view yet. Two rows of text_tail_tests::list_keys_at_list_items asserted that Tab outside a list types a tab; they now assert the text stays as it was. --- crates/engine/src/canvas/textedit.rs | 93 +++++++++++++++++++- crates/engine/src/cmd/text.rs | 2 +- crates/engine/src/keymap.rs | 1 + crates/engine/src/lib.rs | 2 + crates/engine/src/text_tab_tests.rs | 113 +++++++++++++++++++++++++ crates/engine/src/text_tail_tests.rs | 6 +- crates/ui-egui/locales/en.toml | 1 + crates/ui-egui/src/text_enter_tests.rs | 52 +++++++++++- docs/ui-parity.md | 5 +- 9 files changed, 265 insertions(+), 10 deletions(-) create mode 100644 crates/engine/src/text_tab_tests.rs diff --git a/crates/engine/src/canvas/textedit.rs b/crates/engine/src/canvas/textedit.rs index 6c8c15071..b0c09691d 100644 --- a/crates/engine/src/canvas/textedit.rs +++ b/crates/engine/src/canvas/textedit.rs @@ -401,6 +401,94 @@ pub fn list_indent(s: &mut Session, out: bool) -> Result { Ok(text_of(s, id)? != before) } +/// Whether Tab in text layer `id` moves between text layers: not in a board object's text (a +/// sticky's note, a table cell, a code block) or a widget's field, where it types as before. +fn tabs_between_texts(doc: &Document, id: NodeId) -> bool { + !in_board_object(doc, id) && crate::widgets::field_of(doc, id).is_none() +} + +fn in_board_object(doc: &Document, id: NodeId) -> bool { + std::iter::once(id).chain(doc.ancestors(id)).any(|a| doc.node(a).is_some_and(|n| n.board.is_some())) +} + +/// Tab (Shift+Tab: `back`) while editing text layer `from`: editing it ends as Escape ends it, and +/// the next (previous) text layer in reading order is edited with all of its text selected. At the +/// last (first) one nothing happens. +fn tab_to_next_text(s: &mut Session, from: NodeId, back: bool) -> Result<()> { + let order = reading_order(s.doc()?, tab_stops(s.doc()?, from)); + let Some(at) = order.iter().position(|t| *t == from) else { return Ok(()) }; + let next = if back { at.checked_sub(1).and_then(|i| order.get(i)) } else { order.get(at + 1) }; + let Some(&next) = next else { return Ok(()) }; + end(s)?; + begin(s, next, None, false) +} + +/// The text layers Tab moves between from text layer `from`: those in the top-level layer holding +/// it (the frame or group on the page or in a section), at any depth and inside instances, that are +/// visible and unlocked with every layer around them and not in a board object; for a text on the +/// page or in a section itself, the text layers beside it there. `from` is always one of them. +fn tab_stops(doc: &Document, from: NodeId) -> Vec { + let is_section = |id: &NodeId| doc.node(*id).is_some_and(|n| matches!(n.kind, NodeKind::Section { .. })); + let chain: Vec = std::iter::once(from).chain(doc.ancestors(from)).collect(); + let Some(page_at) = chain.iter().position(|c| doc.node(*c).is_some_and(|n| n.is_page())) else { return vec![from] }; + let top = chain.get(..page_at).and_then(|below| below.iter().rev().copied().find(|c| !is_section(c))); + let stop = |n: &figcraft_doc::Node| n.visible && !n.locked && n.board.is_none(); + let mut out = Vec::new(); + match top { + Some(top) if top != from => { + let mut stack = vec![top]; + let mut seen = 0usize; + while let Some(id) = stack.pop() { + seen += 1; + if seen > 1_000_000 { + break; + } + let Some(n) = doc.node(id).filter(|n| stop(n)) else { continue }; + if matches!(n.kind, NodeKind::Text(_)) { + out.push(id); + } + stack.extend(n.children.iter().copied()); + } + } + _ => { + let beside = doc.node(from).and_then(|n| n.parent).and_then(|p| doc.node(p)).map(|p| p.children.clone()).unwrap_or_default(); + out.extend(beside.into_iter().filter(|c| doc.node(*c).is_some_and(|n| stop(n) && matches!(n.kind, NodeKind::Text(_))))); + } + } + if !out.contains(&from) { + out.push(from); + } + out +} + +/// `ids` in reading order by their boxes on the page: rows top to bottom, each row left to right. +/// Rows are made from the top down: a layer joins the row of the topmost layer before it when the +/// two overlap vertically by more than nothing and by at least half the height of the shorter one, +/// else it starts the next row. Layers without bounds are left out. +fn reading_order(doc: &Document, ids: Vec) -> Vec { + let mut boxes: Vec<(NodeId, figcraft_geom::Rect)> = ids.into_iter().filter_map(|i| Some((i, doc.world_bounds(i)?))).collect(); + boxes.sort_by(|a, b| a.1.y0.total_cmp(&b.1.y0).then(a.1.x0.total_cmp(&b.1.x0))); + let mut rows: Vec> = Vec::new(); + for (id, b) in boxes { + let joins = |row: &Vec<(NodeId, figcraft_geom::Rect)>| { + row.first().is_some_and(|(_, a)| { + let overlap = a.y1.min(b.y1) - a.y0.max(b.y0); + overlap > 0.0 && overlap >= 0.5 * a.height().min(b.height()) + }) + }; + match rows.last_mut() { + Some(row) if joins(row) => row.push((id, b)), + _ => rows.push(vec![(id, b)]), + } + } + rows.into_iter() + .flat_map(|mut row| { + row.sort_by(|a, b| a.1.x0.total_cmp(&b.1.x0).then(a.1.y0.total_cmp(&b.1.y0))); + row.into_iter().map(|(id, _)| id) + }) + .collect() +} + /// The kind of word char `i` belongs to: 0 for spaces and punctuation, else its script, so a word /// ends where the script changes (Han, hiragana, katakana and Hangul runs are words of their own in /// text without spaces). Combining marks and voicing marks belong to the char before them. @@ -459,7 +547,9 @@ fn word_right(chars: &[char], mut i: usize) -> usize { i } -/// A named key: Backspace, Delete, Left, Right, Up, Down, Home, End, Enter, Escape, SelectAll. +/// A named key: Backspace, Delete, Left, Right, Up, Down, Home, End, Enter, Tab, Escape, SelectAll. +/// Tab and Shift+Tab outside a list, a code block, a board object and a widget's field edit the +/// next or previous text layer ([`tab_to_next_text`]). /// `word` moves or deletes by word, `line` to the line's ends (Up/Down, Home/End: the text's ends); /// [`crate::keymap::text_motion`] gives them for the platform's keys. `ArrowLeft` etc. also work. pub fn key(s: &mut Session, key: &str, shift: bool, word: bool, line: bool) -> Result<()> { @@ -484,6 +574,7 @@ pub fn key(s: &mut Session, key: &str, shift: bool, word: bool, line: bool) -> R match key { "Escape" => return end(s), "Enter" => return insert(s, "\n"), + "Tab" if !word && !line && tabs_between_texts(s.doc()?, te.id) => return tab_to_next_text(s, te.id, shift), "Tab" => return insert(s, "\t"), "Backspace" | "Delete" => { return edit(s, |t, te| { diff --git a/crates/engine/src/cmd/text.rs b/crates/engine/src/cmd/text.rs index 177155a8a..f80c0c541 100644 --- a/crates/engine/src/cmd/text.rs +++ b/crates/engine/src/cmd/text.rs @@ -642,7 +642,7 @@ pub fn specs() -> Vec { spec!( "text.edit.key", "Text key", - "{key: Backspace|Delete|Left|Right|Up|Down|Home|End|Enter|Tab|Escape|SelectAll, shift?, alt?, cmd?} in a list, Tab nests the item and Shift+Tab, Enter on an empty item or Backspace at its start move it out; in a code block, Tab types two spaces and Enter keeps the line's indent", + "{key: Backspace|Delete|Left|Right|Up|Down|Home|End|Enter|Tab|Escape|SelectAll, shift?, alt?, cmd?} in a list, Tab nests the item and Shift+Tab, Enter on an empty item or Backspace at its start move it out; in a code block, Tab types two spaces and Enter keeps the line's indent; elsewhere Tab and Shift+Tab edit the next or previous text layer of the frame in reading order (rows top to bottom, each left to right), all of it selected, and do nothing at the last and the first (in a board object or a widget's field Tab types a tab)", true, |s, p| { let k = req_string("text.edit.key", p, "key")?; diff --git a/crates/engine/src/keymap.rs b/crates/engine/src/keymap.rs index 11e7e316a..f289fd457 100644 --- a/crates/engine/src/keymap.rs +++ b/crates/engine/src/keymap.rs @@ -365,6 +365,7 @@ pub static GESTURES: &[(Group, &str, &str, &str)] = &[ (Selection, "Pick select: next or previous layer", "⇥ / ⇧⇥", "Tab / Shift+Tab"), (Selection, "Pick select: into a layer, out to its parent", "↵ / ⇧↵", "Enter / Shift+Enter"), (Selection, "Pick select: select the picked layer", "Space", "Space"), + (Text, "While editing text: next or previous text layer", "⇥ / ⇧⇥", "Tab / Shift+Tab"), (Edit, "Duplicate by dragging", "⌥ drag", "Alt+drag"), (Transform, "Nudge (Shift: big nudge)", "← ↑ → ↓", "← ↑ → ↓"), (Transform, "Resize by the nudge amount", "⌘ arrows", "Ctrl+arrows"), diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ad6bb085e..5de6d03bf 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -617,6 +617,8 @@ mod text_motion_tests; #[cfg(test)] mod text_style_picker_tests; #[cfg(test)] +mod text_tab_tests; +#[cfg(test)] mod text_tail_tests; #[cfg(test)] mod text_weight_step_tests; diff --git a/crates/engine/src/text_tab_tests.rs b/crates/engine/src/text_tab_tests.rs new file mode 100644 index 000000000..2f7201290 --- /dev/null +++ b/crates/engine/src/text_tab_tests.rs @@ -0,0 +1,113 @@ +//! Tab and Shift+Tab while editing a text layer move editing to the next or previous text layer +//! of the same top-level frame, in reading order (rows top to bottom, each left to right), with +//! all of its text selected; hidden and locked text is passed over, and at either end the key +//! does nothing. + +use figcraft_doc::NodeId; +use serde_json::{Value, json}; + +use crate::Session; +use crate::params::id_of; + +fn ex(s: &mut Session, cmd: &str, p: Value) -> Value { + s.execute(cmd, &p).unwrap_or_else(|e| panic!("{cmd}: {e}")) +} + +fn text(s: &mut Session, chars: &str, x: f64, y: f64, parent: NodeId) -> NodeId { + id_of(&ex(s, "text.create", json!({"text": chars, "x": x, "y": y, "parent": parent}))["id"]).unwrap() +} + +fn frame(s: &mut Session, x: f64, y: f64) -> NodeId { + id_of(&ex(s, "frame.create", json!({"x": x, "y": y, "width": 400, "height": 300}))["id"]).unwrap() +} + +fn tab(s: &mut Session, shift: bool) { + ex(s, "text.edit.key", json!({"key": "Tab", "shift": shift})); +} + +/// The text being edited and whether all of it is selected. +fn editing(s: &Session) -> (NodeId, bool) { + let te = s.ds().unwrap().text_edit.clone().expect("still editing"); + let n = s.doc().unwrap().node(te.id).unwrap().kind.text().unwrap().char_count(); + (te.id, te.anchor.min(te.caret) == 0 && te.anchor.max(te.caret) == n) +} + +fn chars(s: &Session, id: NodeId) -> String { + s.doc().unwrap().node(id).unwrap().kind.text().unwrap().characters.clone() +} + +/// A frame with a row of three texts whose tops differ by a few pixels, out of order in the +/// layer list, and a second row below; a text in another frame beside it. +fn two_rows(s: &mut Session) -> Vec { + let f = frame(s, 0.0, 0.0); + let b = text(s, "B", 150.0, 12.0, f); + let a = text(s, "A", 10.0, 10.0, f); + let e = text(s, "E", 150.0, 100.0, f); + let c = text(s, "C", 290.0, 6.0, f); + let d = text(s, "D", 10.0, 101.0, f); + let other = frame(s, 500.0, 0.0); + text(s, "Elsewhere", 10.0, 10.0, other); + vec![a, b, c, d, e] +} + +#[test] +fn tab_reads_a_row_left_to_right_then_the_next_row() { + let mut s = Session::new(); + let order = two_rows(&mut s); + ex(&mut s, "text.edit.begin", json!({"id": order[0], "caret": 0})); + for want in &order[1..] { + tab(&mut s, false); + assert_eq!(editing(&s), (*want, true), "on to {} with all of it selected", chars(&s, *want)); + } + assert!(order.iter().all(|t| !chars(&s, *t).contains('\t')), "no tab typed"); +} + +#[test] +fn shift_tab_goes_back() { + let mut s = Session::new(); + let order = two_rows(&mut s); + ex(&mut s, "text.edit.begin", json!({"id": order[4], "caret": 0})); + for want in order[..4].iter().rev() { + tab(&mut s, true); + assert_eq!(editing(&s).0, *want, "back to {}", chars(&s, *want)); + } +} + +#[test] +fn tab_on_the_last_text_keeps_editing_it() { + let mut s = Session::new(); + let order = two_rows(&mut s); + let undo = s.ds().unwrap().history.undo.len(); + ex(&mut s, "text.edit.begin", json!({"id": order[4], "caret": 1})); + tab(&mut s, false); + let te = s.ds().unwrap().text_edit.clone().expect("still editing"); + assert_eq!((te.id, te.caret, te.anchor), (order[4], 1, 1), "the last one: nothing moves"); + assert_eq!(chars(&s, order[4]), "E", "and nothing is typed"); + // Shift+Tab on the first one does nothing either. + ex(&mut s, "text.edit.end", json!({})); + ex(&mut s, "text.edit.begin", json!({"id": order[0], "caret": 0})); + tab(&mut s, true); + assert_eq!(editing(&s).0, order[0]); + ex(&mut s, "text.edit.end", json!({})); + assert_eq!(s.ds().unwrap().history.undo.len(), undo, "no undo step for it"); +} + +#[test] +fn hidden_and_locked_text_is_skipped() { + let mut s = Session::new(); + let f = frame(&mut s, 0.0, 0.0); + let first = text(&mut s, "First", 10.0, 10.0, f); + let hidden = text(&mut s, "Hidden", 10.0, 50.0, f); + ex(&mut s, "node.set", json!({"id": hidden, "props": {"visible": false}})); + let locked = text(&mut s, "Locked", 10.0, 90.0, f); + ex(&mut s, "node.set", json!({"id": locked, "props": {"locked": true}})); + let inner = id_of(&ex(&mut s, "frame.create", json!({"x": 10, "y": 130, "width": 200, "height": 60, "parent": f}))["id"]).unwrap(); + text(&mut s, "In a locked frame", 0.0, 0.0, inner); + ex(&mut s, "node.set", json!({"id": inner, "props": {"locked": true}})); + let last = text(&mut s, "Last", 10.0, 220.0, f); + ex(&mut s, "text.edit.begin", json!({"id": first, "caret": 0})); + tab(&mut s, false); + assert_eq!(editing(&s).0, last, "past the hidden text, the locked one and the text in a locked frame"); + tab(&mut s, true); + assert_eq!(editing(&s).0, first); +} diff --git a/crates/engine/src/text_tail_tests.rs b/crates/engine/src/text_tail_tests.rs index af854a6ea..7ad66d8f7 100644 --- a/crates/engine/src/text_tail_tests.rs +++ b/crates/engine/src/text_tail_tests.rs @@ -221,11 +221,11 @@ fn list_keys_at_list_items() { 2, "Tab", false, - "a\n\tb", + "a\nb", vec![(B, 0), (P, 1)], - "a plain paragraph at a level isn't an item: Tab types a tab", + "a plain paragraph at a level isn't an item: Tab leaves the list alone (and moves to the next text, none here)", ), - ("a\nb", vec![(P, 0), (P, 0)], 3, "Tab", false, "a\nb\t", vec![(P, 0), (P, 0)], "outside a list Tab types a tab"), + ("a\nb", vec![(P, 0), (P, 0)], 3, "Tab", false, "a\nb", vec![(P, 0), (P, 0)], "outside a list Tab types no tab"), ("a", vec![(B, 8)], 1, "Tab", false, "a", vec![(B, 8)], "silent: nesting stops at 8 levels"), ]; for (chars, before, caret, k, shift, after, want, why) in cases { diff --git a/crates/ui-egui/locales/en.toml b/crates/ui-egui/locales/en.toml index e42a1c21c..ec00c152f 100644 --- a/crates/ui-egui/locales/en.toml +++ b/crates/ui-egui/locales/en.toml @@ -1758,6 +1758,7 @@ name = "English" "What it's for" = "What it's for" "What this changed from isn't known: it changed before FigCraft kept a copy of ready-for-dev frames. Resolve the change (or mark it ready again) to compare from now on." = "What this changed from isn't known: it changed before FigCraft kept a copy of ready-for-dev frames. Resolve the change (or mark it ready again) to compare from now on." "When marked ready" = "When marked ready" +"While editing text: next or previous text layer" = "While editing text: next or previous text layer" "While hovering" = "While hovering" "While pressing" = "While pressing" "White" = "White" diff --git a/crates/ui-egui/src/text_enter_tests.rs b/crates/ui-egui/src/text_enter_tests.rs index 89129a7e9..cd0924328 100644 --- a/crates/ui-egui/src/text_enter_tests.rs +++ b/crates/ui-egui/src/text_enter_tests.rs @@ -1,7 +1,8 @@ -//! Enter and Escape on text, and the page a new file gets in each theme, driven through egui +//! Enter, Escape and Tab on text, and the page a new file gets in each theme, driven through egui //! headless: Enter on a selected text layer edits it with all of its text selected (what a //! double-click into it does), typing replaces it, and Escape leaves editing with the layer still -//! selected; File ▸ New in the dark theme makes a dark page. +//! selected; Tab while editing goes on to the next text layer; File ▸ New in the dark theme makes +//! a dark page. use egui::{Event, Key, Modifiers}; use figcraft_color::Color; @@ -12,7 +13,10 @@ use serde_json::json; use crate::layers_drag_tests::Ui; fn press(u: &mut Ui, key: Key) { - let modifiers = Modifiers::NONE; + press_with(u, key, Modifiers::NONE); +} + +fn press_with(u: &mut Ui, key: Key, modifiers: Modifiers) { u.frame(vec![ Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }, Event::Key { key, physical_key: None, pressed: false, repeat: false, modifiers }, @@ -59,6 +63,48 @@ fn enter_edits_a_selected_text_with_all_of_it_selected_and_escape_keeps_the_laye assert!(u.app.session.selection().is_empty()); } +/// The text layer inside instance `inst`. +fn label_of(s: &Session, inst: NodeId) -> NodeId { + let doc = s.doc().unwrap(); + doc.subtree(inst).into_iter().find(|i| doc.node(*i).is_some_and(|n| matches!(n.kind, NodeKind::Text(_)))).unwrap() +} + +#[test] +fn tab_edits_the_label_in_the_next_row_of_a_form() { + // A form: a vertical auto layout frame of instances of an option (a box and a label), each + // label set on its instance. + let mut s = Session::new(); + let id = |v: serde_json::Value| NodeId(v["id"].as_u64().unwrap()); + let option = id(s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 160, "height": 24, "name": "Option"})).unwrap()); + s.execute("node.set", &json!({"id": option, "props": {"layout": "horizontal", "gap": 8}})).unwrap(); + s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 16, "height": 16, "parent": option})).unwrap(); + let main_label = id(s.execute("text.create", &json!({"text": "Label", "x": 0, "y": 0, "parent": option})).unwrap()); + let option = id(s.execute("component.create", &json!({"ids": [option]})).unwrap()); + let form = id(s.execute("frame.create", &json!({"x": 0, "y": 200, "width": 240, "height": 200, "name": "Form"})).unwrap()); + s.execute("node.set", &json!({"id": form, "props": {"layout": "vertical", "gap": 12}})).unwrap(); + let mut labels = Vec::new(); + for name in ["Instagram", "Architect", "Designer"] { + let inst = id(s.execute("instance.create", &json!({"component": option, "parent": form})).unwrap()); + let label = label_of(&s, inst); + s.execute("text.set", &json!({"id": label, "characters": name})).unwrap(); + labels.push(label); + } + s.execute("text.edit.begin", &json!({"id": labels[0], "caret": 9})).unwrap(); + let mut u = Ui::new(s); + press(&mut u, Key::Tab); + let te = u.app.session.ds().unwrap().text_edit.clone().expect("still editing"); + assert_eq!((te.id, te.anchor.min(te.caret), te.anchor.max(te.caret)), (labels[1], 0, 9), "Architect, all of it selected"); + u.frame(vec![Event::Text("Writer".into())]); + assert_eq!(text(&u, labels[1]), "Writer", "typing replaces it"); + assert_eq!((text(&u, labels[0]), text(&u, main_label)), ("Instagram".into(), "Label".into()), "the others stay"); + press_with(&mut u, Key::Tab, Modifiers::SHIFT); + assert_eq!(u.app.session.ds().unwrap().text_edit.as_ref().map(|te| te.id), Some(labels[0]), "Shift+Tab: back to Instagram"); + // An override: the main's label changing leaves it as typed. + press(&mut u, Key::Escape); + u.app.session.execute("text.set", &json!({"id": main_label, "characters": "Choice"})).unwrap(); + assert_eq!(text(&u, labels[1]), "Writer", "kept as the instance's own text"); +} + #[test] fn copying_and_cutting_selected_text_use_clipboard_service() { use std::{cell::RefCell, rc::Rc}; diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..3a5569f87 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** minor (Tab and Shift+Tab while editing a text layer go on to the next or previous text layer of its frame, in reading order, with all of its text selected; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -98,7 +98,7 @@ interaction feel only partly compared: the interactions measured so far, case by | Vector edit mode: bend, paint bucket, lasso, cut, eraser, transform box, point snapping, mirroring | done | a mirror mode on a sharp point turns it smooth by the measured rule (#2110); a double-click a few pixels off a thin stroke enters edit mode (#646); entering edit mode and picking a region keep the canvas still (#322); a point dropped on another point merges with it, and dropping one end of an open path on the other closes it (a 2-point line's end just moves, #401); Flatten keeps open paths open (#377), and bakes a vector's point corner radius into its path (each rounded point becomes the arc's end points joined by curves, the layer stays a vector and its box fits the real geometry, #2195); paint bucket drags across areas; cut drags divide a shape into layers; delete and heal follows the curve; rounded points are drawn, an arc reaching along the whole of a segment whose other end is sharp and half of one whose other end is rounded too, so one rounded corner of a 100 × 100 square with radius 100 runs from one neighbour to the other, while the radius field keeps what was typed (#2334, `vector_radius_tests`, `vector_point_radius_tests`); Shift-click deselects a point at a corner of the box (`vector_behaviour_tests`); several vectors edited at once, Shift-click handles to drag them together, a cap and join per point, rounded points beside curves (`vector_multi_behaviour_tests`); filled regions with the Move tool: the area under the pointer is hatched ("/" lines in the selection colour, clipped by the area's own fill rule, holes left out, gone 3.5 px from a point or 2 px from a segment at any zoom), the line spacing follows octave folding (fitted to measurements at several zoom levels: 8 px at every power-of-two zoom, growing with the zoom and stepping back at √2 · 2ⁿ) and stays fixed to the shape when panning; a click selects the area and its points (moved with it but drawn unselected), Shift adds or removes an area, a press on a selected area drags the whole selection, no hover hatch during drags, a click on an empty spot (a hole) clears it and stays in edit mode; `vector.edit.select {regions}` (`regions_tests`, `vector_regions_tests`); a Bend click on a sharp point between two segments curves it (handles along the line between its neighbours, a third of the way to each, `ops::auto_smooth`), on a curved one sharpens it, a drag sets the handles by hand (#1875); with regions selected, the Fill section (its rows and the colour picker) and `fill.set`, `fill.add`, `fill.remove`, `fill.move` and `fill.paste` edit those regions' own fills, the layer's untouched, or the regions named by `regions: [index, ...]`; Copy fill takes the region's paint, the colour picker and its canvas gradient and crop handles edit it (an image from Upload from computer included; a file dropped on the picker goes to the canvas instead), what belongs to the layer (its fill style, a variable bound to its fill, the image crop button) stays off a region's rows, and `fill.pattern` sets the layer's fill (#1875); the Point section's X and Y show the value the selected points share, or Mixed, and a typed value sets every selected point's own coordinate, in the layer being edited (measured in Figma on 2026-11-08); Copy and Cut with points or segments selected take just those (a lone point: the segments touching it) as a vector with the layer's look, at their own place, so a paste outside edit mode is a new layer in place; Cut removes them as Delete does, the path splitting in the same layer with edit mode staying on; Paste while editing adds the clipboard's segments, or a copied shape's or boolean's outline, to the edited network in place with the new points selected, skipping layers with no outline (text, frames, groups; named in `skipped`) and refusing when none has one, as measured in Figma (`vector_clipboard_tests`, #1875). Not yet: areas of other layers edited at once; the Point section's X and Y over points of several edited layers | | Shape builder (Shift+M) on fills, strokes and open paths; variable width (Shift+W), one side with Alt | done | | | Boolean groups: clicked where the result is, double-click or Cmd/Ctrl-click into operands, live results while dragging or editing points, per-operand operations | done | a group past the path operations' caps (250 000 segments, 2 million possible crossings, 4 million segments swept over a fold) draws without its result, with a warning, and Flatten refuses it (#1104); the Design panel's Boolean groups menu leads Union, Subtract, Intersect and Exclude with their own icons, two offset squares with the result filled at reduced alpha (#2003); a boolean group takes a corner radius from the Design panel and from `node.set cornerRadius`: every sharp corner of its result rounds, convex and concave, layers inside keep their own radius and do not stack with it, a radius larger than the edges allow shrinks to fit while the field keeps the value typed, Flatten bakes the arcs and a mixed selection reads Mixed; measured in Figma's web app on 2026-11-10 (#2222; `crates/pathops/src/round_tests.rs`, `crates/render/src/boolean_radius_tests.rs`, `crates/engine/src/boolean_radius_tests.rs`, the boolean group test in `crates/ui-egui/src/field_tests.rs`). Pinned and not yet compared with Figma: corner smoothing on a boolean group draws the polygon profile between straight edges, a corner beside a curve stays within the curve piece next to it, and there is no radius handle on the canvas | -| Text: point, auto height, fixed; caret, words, lines, IME | done | Backspace or Delete at the start of a list item takes its marker and keeps its level, the paragraph starting where the item's text did ("delete the counter, but keep the same level of indentation", Create bulleted and numbered lists; `text_tail_tests::list_keys_at_list_items`, text crate `behaviour_tests`); max lines on auto-width text keep it auto width, hugging up to that many lines and growing with its longest line ("Text resizing is set to auto height or auto width", Explore text properties; `text_behaviour_tests::max_lines_on_auto_width_text_keeps_auto_width_and_hugs_that_many_lines`); Alt+Enter while editing opens the link at the caret, web and mail links only (`text.openLink`; "press ⌥Option Return/Alt Enter to activate a focused link", Accessibility at Figma; `text_link_tests`); the font picker previews a family on the canvas while hovered (no undo step; Escape restores, #653) and Up/Down step through it (#352); a selection highlight after a line break starts at that line's start and an empty last line shows its mark (#665); carets step over whole emoji and accented letters; colour emoji draw from their colour tables (#300); IME composition replayed in tests as macOS sends it, not yet checked on a Mac (#747); CJK words by script run (no dictionary); vertical trim in Type settings; the caret takes the text's solid fill colour, measured in Figma's web app, 2026-11-09; gradient and image fills (not measured) give a black caret on a light surface and a white one on a dark one (the nearest layer around the text whose top visible fill is a solid at least half opaque as drawn, counting layer opacity, else the page; a layer whose top fill is a gradient or an image is passed over), not the interface's text colour, which is white in the dark theme and vanished on the default light page (#2190) (#2156; `caret_tests`); no spell check | +| Text: point, auto height, fixed; caret, words, lines, IME | done | Backspace or Delete at the start of a list item takes its marker and keeps its level, the paragraph starting where the item's text did ("delete the counter, but keep the same level of indentation", Create bulleted and numbered lists; `text_tail_tests::list_keys_at_list_items`, text crate `behaviour_tests`); Tab and Shift+Tab while editing a text layer that isn't a list item go on to the next or previous text layer of its frame in reading order, all of its text selected, and do nothing at the last and the first (`text_tab_tests`); max lines on auto-width text keep it auto width, hugging up to that many lines and growing with its longest line ("Text resizing is set to auto height or auto width", Explore text properties; `text_behaviour_tests::max_lines_on_auto_width_text_keeps_auto_width_and_hugs_that_many_lines`); Alt+Enter while editing opens the link at the caret, web and mail links only (`text.openLink`; "press ⌥Option Return/Alt Enter to activate a focused link", Accessibility at Figma; `text_link_tests`); the font picker previews a family on the canvas while hovered (no undo step; Escape restores, #653) and Up/Down step through it (#352); a selection highlight after a line break starts at that line's start and an empty last line shows its mark (#665); carets step over whole emoji and accented letters; colour emoji draw from their colour tables (#300); IME composition replayed in tests as macOS sends it, not yet checked on a Mac (#747); CJK words by script run (no dictionary); vertical trim in Type settings; the caret takes the text's solid fill colour, measured in Figma's web app, 2026-11-09; gradient and image fills (not measured) give a black caret on a light surface and a white one on a dark one (the nearest layer around the text whose top visible fill is a solid at least half opaque as drawn, counting layer opacity, else the page; a layer whose top fill is a gradient or an image is passed over), not the interface's text colour, which is white in the dark theme and vanished on the default light page (#2190) (#2156; `caret_tests`); no spell check | | Text: wrap style (Auto, Balance, Pretty) | done | per text layer (`wrapStyle` on `node.set`, `text.wrapStyle`, the Type settings control under Vertical trim, inspect, CSS `text-wrap: balance` or `pretty`): Auto breaks greedily; Balance narrows each paragraph as far as it goes without another line, so its lines come out close to the same length (what browsers do for `text-wrap: balance`); Pretty keeps lines full and, when the last line is one word, narrows one of the last four lines just enough to give a word to the lines after it (Explore text properties: "Auto: Figma fits as many words as possible on each line before wrapping to the next", "Balance: Figma distributes text as evenly as possible across every line, so each line is close to the same length", "Pretty: Figma keeps each line full, but adjusts the last four lines to avoid an orphan"). Saved line breaks from a file still win. At three levels (the text layer, a paragraph and a text style, per Explore text properties): the paragraph level is the caret's or the selection's paragraphs while editing (`text.wrapStyle`; the control follows them), or `start`/`end` on `node.set wrapStyle` (a paragraph's own style beats the layer's; setting the layer sets every paragraph again; Enter carries it to the new paragraph; inspect reports `lineWrapStyles` when paragraphs differ and CSS `text-wrap` only when they agree); the text-style level is a style's `wrapStyle` (shown read-only in the style editor, applied with the style, moved by `style.update`, unlinking when edited). The `.fig` import/export mapping stays open (#1827): a `.fig` export leaves the wrap styles out and a `.fig` import reads every text as Auto, so the wrap styles are lost through a `.fig` round trip. Test: `text_behaviour_tests::wrap_style_per_paragraph_overrides_the_layers`, `styles_behaviour_tests::text_styles_carry_the_wrap_style`, `text_behaviour_tests::balance_and_pretty_wrap_styles_break_lines_as_documented` | | Text: direction override (Text ▸ Text direction) | done | per paragraph (`ParaList::direction`: auto, ltr, rtl): Text ▸ Text direction ▸ Auto / Left to right / Right to left and `text.direction {direction, ids?}` set the edited paragraphs while editing, else every paragraph of the selected texts; `node.set textDirection` the layer's (or the chars `start`/`end` name); the Type settings control appears once a right-to-left script is in the text or a direction is forced; inspect reports `textDirection` when the paragraphs agree and `lineDirections` otherwise; Developer Mode's CSS writes `direction: ltr` or `rtl` when every paragraph is forced the same way (with `text-align: left` beside `rtl`, as Left is absolute on the canvas); `.fig` import and export carry each line's `sourceDirectionality`, read up to the paragraph count. Layout gives the paragraph its base level, so a forced right-to-left paragraph of Latin letters starts at the right, mirrors its list gutter and indent and orders its runs right to left, and a forced left-to-right paragraph of Hebrew the other way ("By default, Figma automatically handles text direction based on language detection. However, controls are available to override text direction per paragraph", "Go to Text > Text direction. Select Left to right or Right to left", Add right-to-left text). Not included: a direction in text styles (the article names none). Tests: `text_behaviour_tests::text_direction_is_forced_per_paragraph`, `fig::text_direction_tests` | | Text: superscript and subscript | done | `sups` / `subs` use the font's own glyphs where it has the feature and every letter or digit of the run gets one; otherwise the standard glyphs are drawn shrunk and raised or lowered by the font's OS/2 superscript and subscript metrics (0.65 em at 0.35 em up or 0.14 em down without them), and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says ("Figma draws a synthesized version by using the font's standard version of the character, shrinking it, and positioning it accordingly"; mixed glyphs "all update to the synthesized form for consistency"), #1828; tests `text::tests::superscript_native_or_synthesised_and_never_mixed`, `text_behaviour_tests::superscript_and_subscript_are_synthesised_without_glyphs_for_them`. Type settings ▸ Details ▸ Position (None, Superscript, Subscript) sets them on the selected layers (#2338); a range of characters can't be raised alone yet, as the features are the layer's | @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-20 | patch | M4: Tab while editing a text layer typed a tab character, and Shift+Tab did too, so filling in a form built from instances took a double-click into every label. Tab now ends editing and edits the next text layer with all of its text selected, so typing replaces it; Shift+Tab goes to the previous one. The order is reading order: rows top to bottom, each left to right, and two layers share a row when they overlap vertically by at least half the shorter one's height. The candidates are the text layers of the same top-level frame or group, at any depth and inside instances (what is typed there is the instance's override), that are visible and unlocked along with every layer around them; a text on the page or in a section goes to the text layers beside it there. At the last text Tab does nothing, and Shift+Tab at the first, with no wrapping. In a list item Tab still nests the item, in a code block it still types two spaces, and in a board object or a widget's field it still types a tab. The view doesn't follow a text that is off screen: nothing in the app scrolls a layer into view yet. Tests: `text_tab_tests`, `text_enter_tests::tab_edits_the_label_in_the_next_row_of_a_form` | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 8056e20dcf6840650e5ec2899b820410e2445c19 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Sun, 22 Nov 2026 16:50:07 -0500 Subject: [PATCH 16/36] M3: a variant switch keeps typed text the other variant nests in other frames Switching an instance to another variant matched its old layers to the new variant's by source and then by name path. When the two variants nest the same text layer differently (text > Label in one, div > text > Label in the other), the path differs, the typed layer matched nothing, and the new variant's own text came back. A text layer of the new variant that nothing else matched now takes the old text layer of the same name, when exactly one layer on each side has that name. Two of one name stay unmatched, since either could be the one typed into. Layers inside nested instances are left to their own mains' rebuild, so a text layer never moves between instances. Matching every layer kind by name alone was left out: a fill or size kept from another place in the tree would land on a layer that only shares a name, while text is what was typed and the layer most likely to be the same one. --- crates/engine/src/assets/components/sync.rs | 48 ++++++++++++++++++++ crates/engine/src/assets/components/tests.rs | 35 ++++++++++++++ docs/components-parity.md | 5 +- docs/mcp.md | 3 +- 4 files changed, 88 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/assets/components/sync.rs b/crates/engine/src/assets/components/sync.rs index b8c9bdf8d..d0e7a6eac 100644 --- a/crates/engine/src/assets/components/sync.rs +++ b/crates/engine/src/assets/components/sync.rs @@ -115,9 +115,57 @@ fn match_layers( } m.map.insert(*s, nid); } + match_text_by_name(doc, inst, component, old, &mut m); m } +/// Main text layers nothing matched take the unmatched old text layer of the same name, when +/// exactly one of each has it: text typed into an instance stays when it switches to a variant that +/// nests the same text layer in other frames (its name path differs). Only layers outside nested +/// instances, which rebuild from their own mains. +fn match_text_by_name(doc: &Document, inst: NodeId, component: NodeId, old: &BTreeMap>, m: &mut Matched) { + fn unique(pairs: impl Iterator) -> BTreeMap { + let mut seen: BTreeMap> = BTreeMap::new(); + for (k, id) in pairs { + seen.entry(k).and_modify(|e| *e = None).or_insert(Some(id)); + } + seen.into_iter().filter_map(|(k, id)| Some((k, id?))).collect() + } + let text = |n: &Node| matches!(n.kind, NodeKind::Text(_)); + let mains = unique( + m.fresh.iter().filter_map(|s| doc.node(*s)).filter(|s| text(s) && outside_nested(doc, s.id, component)).map(|s| (s.name.clone(), s.id)), + ); + if mains.is_empty() { + return; + } + let olds = unique( + old.iter() + .filter(|(id, o)| text(o) && !m.used.contains(id) && outside_nested(doc, **id, inst)) + .map(|(id, o)| (o.source.and_then(|s| doc.node(s)).map_or(&o.name, |s| &s.name).clone(), *id)), + ); + for (name, s) in mains { + if let Some(o) = olds.get(&name) { + m.used.insert(*o); + m.map.insert(s, *o); + m.fresh.retain(|f| *f != s); + } + } +} + +/// Whether layer `id` is below `root` with no instance between them. +fn outside_nested(doc: &Document, id: NodeId, root: NodeId) -> bool { + let mut cur = doc.node(id).and_then(|n| n.parent); + for _ in 0..=1_000_000 { + match cur.and_then(|c| doc.node(c)) { + Some(n) if n.id == root => return true, + Some(n) if matches!(n.kind, NodeKind::Instance { .. }) => return false, + Some(n) => cur = n.parent, + None => return false, + } + } + false +} + /// A rebuild's copies of the main's layers, pre-order (parents first). struct Copies { nodes: Vec, diff --git a/crates/engine/src/assets/components/tests.rs b/crates/engine/src/assets/components/tests.rs index fc7d21e86..6bc8e83c5 100644 --- a/crates/engine/src/assets/components/tests.rs +++ b/crates/engine/src/assets/components/tests.rs @@ -282,6 +282,41 @@ fn variant_switch_keeps_compatible_overrides() { healthy(&s); } +#[test] +fn typed_text_stays_across_variants_that_nest_it_differently() { + let mut s = Session::new(); + // Each variant's Label layers, by the frames holding them. + let shapes: [(&str, &[&[&str]]); 3] = [("Kind=Plain", &[&["text"]]), ("Kind=Boxed", &[&["div", "text"]]), ("Kind=Twice", &[&["a"], &["b"]])]; + let mut labels = Vec::new(); + let mut variants = Vec::new(); + for (k, (name, paths)) in shapes.into_iter().enumerate() { + let v = idv(&ex(&mut s, "frame.create", json!({"x": k as f64 * 300.0, "y": 0, "width": 200, "height": 60, "name": name}))); + for frames in paths { + let mut parent = v; + for f in *frames { + parent = idv(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 200, "height": 60, "parent": parent, "name": f}))); + } + labels.push(idv(&ex(&mut s, "text.create", json!({"text": "I agree", "x": 0, "y": 0, "parent": parent, "props": {"name": "Label"}})))); + } + variants.push(idv(&ex(&mut s, "component.create", json!({"ids": [v]})))); + } + ex(&mut s, "component.combineVariants", json!({"ids": variants.clone()})); + let i = idv(&ex(&mut s, "instance.create", json!({"component": variants[0], "x": 0, "y": 300}))); + let typed = copy_of(&s, i, labels[0]); + ex(&mut s, "text.set", json!({"id": typed, "characters": "Architect"})); + + ex(&mut s, "instance.setProperties", json!({"ids": [i], "properties": {"Kind": "Boxed"}})); + healthy(&s); + assert_eq!(chars(&s, copy_of(&s, i, labels[1])), "Architect", "one frame deeper, same name"); + ex(&mut s, "instance.setProperties", json!({"ids": [i], "properties": {"Kind": "Plain"}})); + assert_eq!(chars(&s, copy_of(&s, i, labels[0])), "Architect", "and back"); + + ex(&mut s, "instance.setProperties", json!({"ids": [i], "properties": {"Kind": "Twice"}})); + healthy(&s); + let texts: Vec = labels[2..].iter().map(|l| chars(&s, copy_of(&s, i, *l))).collect(); + assert_eq!(texts, ["I agree", "I agree"], "two layers of that name: neither is the one typed into"); +} + #[test] fn detach_keeps_the_look() { let mut s = Session::new(); diff --git a/docs/components-parity.md b/docs/components-parity.md index fa4d2494e..bd50c9e62 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-22 · **Change:** minor (switching variants keeps the text typed into an instance when the other variant nests that text layer in other frames, matched by its name; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -20,7 +20,7 @@ accounts). | Component sets / variants, add variant, switch | done | Combine as variants is in the Object menu, and the canvas and layers context menu and the Design panel offer it when two or more main components are selected; Add variant on a main component not in a set yet makes it a set of itself and the new variant, one undo step (#903); components that are variants already aren't combined again (it used to put a set inside a set); combining gives every variant the component properties any of them had, so another variant's layers can be bound to one made before combining | | A main's copy within its file is an instance of it: Duplicate, Alt-drag, Copy then Paste | done | a variant duplicated in its set stays a new variant and a whole set copies as a new set; only the copied roots become instances (a main inside a copied frame is copied as a main); Cut then Paste and pastes into other files keep the component (#892) | | A component can't contain its own instance, directly or through other components | done | refused with the loop named (creating, placing, swapping, switching variants, moving, pasting, an instance-swap value); each variant counts as its own component, so a variant may hold a sibling variant's instance unless that one leads back to it; a dropped instance lands on the page; a file holding a loop opens with one instance detached and a note, any other file unchanged; a loop merged in a live session stops expanding where an instance would show itself again (#1084) | -| Switching variants keeps overrides where names match and both variants had the same value; text layers keep theirs | done | | +| Switching variants keeps overrides where names match and both variants had the same value; text layers keep theirs | done | a text layer the other variant nests in other frames is matched by its name when one layer on each side has it | | Default variant: the top-left one (new instances, Assets thumbnail, generated code) | done | | | Variant property order (names rewritten), duplicate combinations reported | done | drag a property in the Properties section to reorder it, one undo step (#679), or `component.editProperty {index}`; a variant value too long for its field ends with an ellipsis and shows whole on hover (#2368) | | Properties: boolean, text, instance swap (preferred values), variant | done | listed in the order they were made, a rename keeping the place (#1536; the shared ones don't reorder by drag yet); every component menu scrolls past 320 pt, the default of an instance-swap property's too (#1338); the instance-swap menus (an instance's property and swap menus, a property's default, the playground) open with a search field that filters by name as you type, with Up, Down and Enter to pick and Escape to clear then close; the slot and preferred components menus have no search yet; an instance lists the properties its variant's layers use, so a set with one text property per variant shows one text field per instance (#2022; measured in Figma's web app, 2026-11-11); long names are cut to one line, the full name on hover | @@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Date | Change | Summary | |---|---|---| +| 2026-11-22 | patch | M3: switching an instance to another variant put back the variant's own text in place of the text typed into it when the two variants nest that text layer in different frames (`text › Label` in one, `div › text › Label` in the other), because the typed layer was matched to the new variant's by name path only. Now a text layer of the new variant nothing else matched takes the old text layer of the same name, when exactly one layer on each side has that name; layers inside nested instances still go by their own mains. Two layers of one name stay unmatched, since either could be the one typed into. Test: `typed_text_stays_across_variants_that_nest_it_differently`. Grade unchanged. | | 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`::S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. | | 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. | | 2026-11-18 | minor | M3, gap 10: library analytics count insertions and detachments of styles and variables. Applying one, or copying or duplicating content that uses it, inserts it; the Detach button detaches it; an instance counts as its component alone. Show usage and `library.usage` give them per style and variable over the chosen period. Modes aren't counted. Numbers unchanged. Tests: `library_asset_counts_tests`, `library_assets_tests`. | diff --git a/docs/mcp.md b/docs/mcp.md index c1f3992a9..e0e264665 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1109,7 +1109,8 @@ most when it can't be reached). the instance itself (its layers follow the main's constraints) or edit the main. - **Variants**: `instance.setProperties {ids?, properties}` switching variants keeps an override where the layer's name path matches and both variants had the same value for that property; - text layers keep all theirs. The default variant (`instance.create` with a set, the Assets + text layers keep all theirs, and a text layer the other variant nests elsewhere is matched by + its name when one layer on each side has it. The default variant (`instance.create` with a set, the Assets thumbnail) is the one in the set's top-left corner; `component.editProperty {name, default}` moves the chosen variant there, `{name, index}` reorders variant properties (the variants' names follow). `component.properties` on a set reports `conflicts`: variants sharing one From 80c68ee7a914c53db7d99279a734cf27cbf2c673 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:45:18 -0500 Subject: [PATCH 17/36] M1: Paste over selection with several layers selected pastes after the last of them With several layers selected, Shift+Cmd/Ctrl+V took the first one selected, so the copies landed among the others. It now pastes after the last selected layer as seen: the last in one auto layout frame's flow, else below the lowest at the selection's own gap, or right of the rightmost for a row. One selected layer is unchanged. --- crates/engine/src/cmd/edit/clipboard.rs | 42 +++++++++++-- crates/engine/src/lib.rs | 2 + crates/engine/src/paste_over_tests.rs | 80 +++++++++++++++++++++++++ docs/ui-parity.md | 3 +- 4 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 crates/engine/src/paste_over_tests.rs diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 98d3eff25..9e51d629d 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -394,14 +394,16 @@ fn copied_variants_set(doc: &Document, copied: &[(NodeId, Vec)]) -> Option sets.all(|set| set == Some(first)).then_some(first) } +/// Paste over selection (Shift+Cmd/Ctrl+V): the copies go into the parent of the selected layer +/// [`last_seen`] picks, just above it, at the place it gives. pub(super) fn paste_over(s: &mut Session, _p: &Value) -> Result { let sel = s.selection(); let page = s.page()?; let doc = s.doc()?; - let (parent, at, above) = match sel.first() { - Some(i) => { - let parent = doc.node(*i).and_then(|n| n.parent).unwrap_or(page); - (parent, doc.world_bounds(*i).map(|b| (b.x0, b.y0)), doc.index_in_parent(*i).map(|ix| ix + 1)) + let (parent, at, above) = match last_seen(doc, &sel) { + Some((i, at)) => { + let parent = doc.node(i).and_then(|n| n.parent).unwrap_or(page); + (parent, at, doc.index_in_parent(i).map(|ix| ix + 1)) } None => (page, None, None), }; @@ -411,6 +413,38 @@ pub(super) fn paste_over(s: &mut Session, _p: &Value) -> Result { Ok(json!({"ids": ids})) } +/// The selected layer Paste over selection pastes after, and where the copies' top-left goes. +/// +/// One layer: that layer, at its position. Several in one auto layout frame: the last of them in the +/// flow, which the layout follows. Several elsewhere: the lowest (then rightmost), with the copies +/// below it, as far below as it is from the selected layers above it. A selection with nothing above +/// its lowest layer is a row: the copies go right of the rightmost, as far as it is from its +/// neighbour on the left. Layers that overlap every way get the copies right under the lowest. +fn last_seen(doc: &Document, sel: &[NodeId]) -> Option<(NodeId, Option<(f64, f64)>)> { + let first = *sel.first()?; + let top_left = |i: NodeId| doc.world_bounds(i).map(|b| (b.x0, b.y0)); + if sel.len() == 1 { + return Some((first, top_left(first))); + } + let parent = doc.node(first).and_then(|n| n.parent); + let one_flow = + parent.and_then(|p| doc.node(p)).is_some_and(|p| p.layout.is_some()) && sel.iter().all(|i| doc.node(*i).is_some_and(|n| n.parent == parent)); + if one_flow { + let last = sel.iter().copied().max_by_key(|i| doc.index_in_parent(*i))?; + return Some((last, top_left(last))); + } + let boxes: Vec<(NodeId, figcraft_geom::Rect)> = sel.iter().filter_map(|i| Some((*i, doc.world_bounds(*i)?))).collect(); + let (lowest, low) = *boxes.iter().max_by(|(_, a), (_, b)| a.y1.total_cmp(&b.y1).then(a.x1.total_cmp(&b.x1)))?; + if let Some(above) = boxes.iter().filter(|(_, o)| o.y1 <= low.y0).map(|(_, o)| o.y1).max_by(f64::total_cmp) { + return Some((lowest, Some((low.x0, low.y1 + (low.y0 - above))))); + } + let (rightmost, right) = *boxes.iter().max_by(|(_, a), (_, b)| a.x1.total_cmp(&b.x1).then(a.y1.total_cmp(&b.y1)))?; + match boxes.iter().filter(|(_, o)| o.x1 <= right.x0).map(|(_, o)| o.x1).max_by(f64::total_cmp) { + Some(left) => Some((rightmost, Some((right.x1 + (right.x0 - left), right.y0)))), + None => Some((lowest, Some((low.x0, low.y1)))), + } +} + pub(super) fn paste_replace(s: &mut Session, p: &Value) -> Result { let targets = req_targets("edit.pasteReplace", s, p)?; let mut out = Vec::new(); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ad6bb085e..8814d5be3 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -483,6 +483,8 @@ mod panels_behaviour_tests; #[cfg(test)] mod paste_missing_image_tests; #[cfg(test)] +mod paste_over_tests; +#[cfg(test)] mod paste_sibling_tests; #[cfg(test)] mod path_read_caps_tests; diff --git a/crates/engine/src/paste_over_tests.rs b/crates/engine/src/paste_over_tests.rs new file mode 100644 index 000000000..3aaf7fbd7 --- /dev/null +++ b/crates/engine/src/paste_over_tests.rs @@ -0,0 +1,80 @@ +//! Shift+Cmd/Ctrl+V with several layers selected pastes after the last of them as seen. + +use serde_json::{Value, json}; + +use crate::Session; +use crate::params::id_of; +use figcraft_doc::NodeId; + +fn id(v: &Value) -> NodeId { + id_of(&v["id"]).unwrap() +} + +fn frame(s: &mut Session, x: f64, y: f64) -> NodeId { + id(&s.execute("frame.create", &json!({"x": x, "y": y, "width": 200, "height": 100})).unwrap()) +} + +fn kids(s: &Session, parent: NodeId) -> Vec { + s.doc().unwrap().node(parent).unwrap().children.clone() +} + +fn paste_over(s: &mut Session, sel: Vec) -> Vec { + s.set_selection(sel); + s.execute("edit.pasteOver", &json!({})).unwrap()["ids"].as_array().unwrap().iter().filter_map(id_of).collect() +} + +fn top_left(s: &Session, n: NodeId) -> (f64, f64) { + let b = s.doc().unwrap().world_bounds(n).unwrap(); + (b.x0, b.y0) +} + +#[test] +fn several_rows_of_an_auto_layout_selected_get_the_copy_after_the_last_row() { + let mut s = Session::new(); + let rows: Vec = + (0..4).map(|k| id(&s.execute("shape.rectangle", &json!({"x": 0, "y": k * 30, "width": 40, "height": 20})).unwrap())).collect(); + let r = s.execute("layout.add", &json!({"ids": rows, "direction": "vertical"})).unwrap(); + let list = id_of(&r["ids"][0]).unwrap(); + assert_eq!(kids(&s, list), rows); + s.execute("edit.copy", &json!({"ids": [rows[0]]})).unwrap(); + // Clicked from the middle down and back: the click order isn't the order on screen. + let pasted = paste_over(&mut s, vec![rows[1], rows[3], rows[2]]); + assert_eq!(pasted.len(), 1); + assert_eq!(kids(&s, list), vec![rows[0], rows[1], rows[2], rows[3], pasted[0]], "after the last selected row"); + assert_eq!(s.selection(), pasted); +} + +#[test] +fn several_artboards_in_a_column_get_the_copy_below_the_lowest_with_their_gap() { + let mut s = Session::new(); + let (a, b, c) = (frame(&mut s, 0.0, 0.0), frame(&mut s, 0.0, 140.0), frame(&mut s, 0.0, 280.0)); + let source = frame(&mut s, 1000.0, 0.0); + s.execute("edit.copy", &json!({"ids": [source]})).unwrap(); + let pasted = paste_over(&mut s, vec![a, c, b]); + assert_eq!(pasted.len(), 1); + assert_eq!(top_left(&s, pasted[0]), (0.0, 420.0), "below the lowest artboard, 40 below it like the others"); + let page = s.doc().unwrap().node(c).unwrap().parent.unwrap(); + let order = kids(&s, page); + let at = |n: NodeId| order.iter().position(|i| *i == n).unwrap(); + assert_eq!(at(pasted[0]), at(c) + 1, "just above the lowest artboard"); +} + +#[test] +fn several_artboards_in_a_row_get_the_copy_right_of_the_rightmost_with_their_gap() { + let mut s = Session::new(); + let (a, b, c) = (frame(&mut s, 0.0, 0.0), frame(&mut s, 260.0, 0.0), frame(&mut s, 520.0, 0.0)); + let source = frame(&mut s, 0.0, 1000.0); + s.execute("edit.copy", &json!({"ids": [source]})).unwrap(); + let pasted = paste_over(&mut s, vec![b, a, c]); + assert_eq!(top_left(&s, pasted[0]), (780.0, 0.0), "right of the rightmost, 60 from it like the others"); +} + +#[test] +fn several_overlapping_layers_get_the_copy_right_under_the_lowest() { + let mut s = Session::new(); + let (a, b) = (frame(&mut s, 0.0, 0.0), frame(&mut s, 50.0, 30.0)); + let source = frame(&mut s, 1000.0, 0.0); + s.execute("edit.copy", &json!({"ids": [source]})).unwrap(); + let pasted = paste_over(&mut s, vec![b, a]); + assert_eq!(top_left(&s, pasted[0]), (50.0, 130.0)); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..228f1443c 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** minor (Shift+Cmd/Ctrl+V with several layers selected pastes after the last of them as seen: next in an auto layout frame's flow, else below the lowest or right of the rightmost, at the selection's own gap; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-20 | patch | M1: Shift+Cmd/Ctrl+V (Paste over selection) with several layers selected took the first one selected, so the copies landed among the others, after whichever was clicked first. It now pastes after the last selected layer as seen: in one auto layout frame, the last of them in the flow, the copies coming next; elsewhere below the lowest, as far below it as it is from the selected layers above it, or, for a row with nothing above its lowest layer, right of the rightmost at the row's gap, in that layer's parent just above it. One selected layer is unchanged. Tests: `paste_over_tests` (4). | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From fd45d4f05b3e7d95e7b52f0a8c8e386aaf6e9079 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:59:12 -0500 Subject: [PATCH 18/36] M3: a main pasted from its library file into another file is an instance of it Copying a main component in a library file and pasting it into another file made a copy of the main there: a new component of that file, not linked to the library. Copy then Paste of a main in its own file already makes an instance, and pasting an instance from the library file already uses the main from the library. Now a main the source file publishes is an instance of it from that library too, which gets enabled the same way, as Figma does with a published component. A variant is an instance of that variant. A main the library doesn't offer (hidden from publishing, added since the last publish) and a main from a file that publishes no library still paste as a copy. Making those an instance as well was rejected: their main would stay in the other file, so the instance would show a missing main. The part of adopt_pasted that brings published components in is now from_published, shared with the new published_main. --- crates/engine/src/assets/library.rs | 56 +++++++++++++-------- crates/engine/src/assets/library/tests.rs | 59 +++++++++++++++++++++++ crates/engine/src/cmd/edit/clipboard.rs | 21 +++++--- docs/components-parity.md | 5 +- docs/mcp.md | 2 + docs/target-app-parity.md | 3 +- 6 files changed, 116 insertions(+), 30 deletions(-) diff --git a/crates/engine/src/assets/library.rs b/crates/engine/src/assets/library.rs index c5b3c1ba0..99f4b07dd 100644 --- a/crates/engine/src/assets/library.rs +++ b/crates/engine/src/assets/library.rs @@ -1417,25 +1417,7 @@ pub fn adopt_pasted(doc: &mut Document, src: &Document, src_path: Option<&str>, remote.extend(merge_components(doc, src, &BTreeMap::new(), Some(&foreign))?); } // Components `src` publishes: from its library. - if let Some(lib) = src.published.as_ref().filter(|l| own.as_deref() != Some(l.manifest.id.as_str())) { - let keys: Vec = - roots.iter().copied().filter(|r| !src.is_remote(*r) && lib.manifest.component(*r).is_some() && lib.doc.contains(*r)).collect(); - if !keys.is_empty() { - remote.extend(import(doc, lib, &keys, false)?); - let m = &lib.manifest; - if doc.libraries.link(&m.id).is_none() - && let Some(path) = src_path - { - doc.libraries_mut().enabled.push(LibraryLink { - id: m.id.clone(), - name: m.name.clone(), - path: path.to_string(), - version: m.version, - relative: String::new(), - }); - } - } - } + remote.extend(from_published(doc, src, src_path, &roots)?); // Point the pasted layers at those mains; what stays behind gets ids of its own. let mut behind: BTreeMap = BTreeMap::new(); let mut follow = |doc: &mut Document, id: NodeId| -> NodeId { @@ -1474,6 +1456,42 @@ pub fn adopt_pasted(doc: &mut Document, src: &Document, src_path: Option<&str>, Ok(()) } +/// `doc`'s copies of the components among `roots` (assets of `src`) that `src` publishes as a +/// library (`src`'s ids → `doc`'s), taken from that library, which gets enabled in `doc` when `src` +/// is saved at `src_path`. Empty when `src` publishes no library, or publishes `doc`'s own. +fn from_published(doc: &mut Document, src: &Document, src_path: Option<&str>, roots: &[NodeId]) -> Result> { + let own = doc.published.as_ref().map(|p| p.manifest.id.as_str()); + let Some(lib) = src.published.as_ref().filter(|l| own != Some(l.manifest.id.as_str())) else { return Ok(BTreeMap::new()) }; + let keys: Vec = + roots.iter().copied().filter(|r| !src.is_remote(*r) && lib.manifest.component(*r).is_some() && lib.doc.contains(*r)).collect(); + if keys.is_empty() { + return Ok(BTreeMap::new()); + } + let remote = import(doc, lib, &keys, false)?; + let m = &lib.manifest; + if doc.libraries.link(&m.id).is_none() + && let Some(path) = src_path + { + doc.libraries_mut().enabled.push(LibraryLink { + id: m.id.clone(), + name: m.name.clone(), + path: path.to_string(), + version: m.version, + relative: String::new(), + }); + } + Ok(remote) +} + +/// The main in `doc` that pasting main component `main`, copied from another document `src`, +/// makes an instance of: `doc`'s copy of it from the library `src` publishes, as +/// [`adopt_pasted`] uses for instances. `None` when `src` doesn't publish it, so the paste copies +/// the main itself. +pub fn published_main(doc: &mut Document, src: &Document, src_path: Option<&str>, main: NodeId) -> Result> { + let Some(root) = asset_root(src, main) else { return Ok(None) }; + Ok(from_published(doc, src, src_path, &[root])?.get(&main).copied()) +} + /// Refuse edits of library copies, except by library commands (and imports of other files, /// which bring their copies along). pub fn check_read_only(cmd: &str, before: &Document, after: &Document) -> std::result::Result<(), String> { diff --git a/crates/engine/src/assets/library/tests.rs b/crates/engine/src/assets/library/tests.rs index 4c329cb5f..ca4233381 100644 --- a/crates/engine/src/assets/library/tests.rs +++ b/crates/engine/src/assets/library/tests.rs @@ -695,3 +695,62 @@ fn library_links_follow_a_moved_folder() { link_found(&mut s, &lid); let _ = std::fs::remove_dir_all(&d); } + +/// A main component copied from a library file and pasted into another file is an instance of it +/// from that library, which gets enabled, as pasting an instance of it is; a variant is an instance +/// of that variant. A component the library doesn't offer pastes as a copy of itself. +#[test] +fn a_main_pasted_from_its_library_file_is_an_instance_of_it() { + let d = dir("paste-main"); + let lib_path = path_str(&d.join("kit.figcraft")); + let mut s = Session::new(); + let k = kit(&mut s); + let sizes: Vec = ["Size=S", "Size=L"] + .iter() + .enumerate() + .map(|(n, name)| { + idv(&ex( + &mut s, + "node.create", + json!({"type": "component", "name": name, "x": 600.0 + n as f64 * 100.0, "y": 0, "width": 40, "height": 20}), + )) + }) + .collect(); + ex(&mut s, "component.combineVariants", json!({"ids": sizes.clone()})); + let spare = idv(&ex(&mut s, "frame.create", json!({"x": 300, "y": 300, "width": 10, "height": 10, "name": "_Spare"}))); + let spare = idv(&ex(&mut s, "component.create", json!({"ids": [spare]}))); + let lid = publish_to(&mut s, &lib_path); + let at = s.doc().unwrap().world_bounds(k.button).unwrap(); + ex(&mut s, "file.new", json!({"name": "Design"})); + let paste = |s: &mut Session, main: NodeId| -> NodeId { + ex(s, "doc.switch", json!({"index": 0})); + ex(s, "edit.copy", json!({"ids": [main]})); + ex(s, "doc.switch", json!({"index": 1})); + id_of(&ex(s, "edit.paste", json!({}))["ids"][0]).unwrap() + }; + let main_of = |s: &Session, id: NodeId| match node(s, id).kind { + NodeKind::Instance { component, .. } => component, + k => panic!("not an instance: {k:?}"), + }; + let button = paste(&mut s, k.button); + let doc = s.doc().unwrap(); + assert_eq!(library_source(doc, main_of(&s, button)), Some((lid.as_str(), k.button))); + assert_eq!(doc.libraries.enabled.iter().map(|l| l.path.as_str()).collect::>(), [lib_path.as_str()]); + assert_eq!(doc.world_bounds(button), Some(at), "where the main was"); + let label = node(&s, button).children[0]; + assert_eq!(chars(&s, label), "OK"); + healthy(&s); + let copies = s.doc().unwrap().libraries.components.len(); + let again = paste(&mut s, k.button); + assert_eq!(main_of(&s, again), main_of(&s, button), "the same library copy"); + assert_eq!(s.doc().unwrap().libraries.components.len(), copies); + let large = paste(&mut s, sizes[1]); + assert_eq!(library_source(s.doc().unwrap(), main_of(&s, large)), Some((lid.as_str(), sizes[1]))); + let card = paste(&mut s, k.card); + assert_eq!(library_source(s.doc().unwrap(), main_of(&s, card)), Some((lid.as_str(), k.card))); + let copy = paste(&mut s, spare); + assert!(matches!(node(&s, copy).kind, NodeKind::Component { .. }), "not offered by the library: a copy"); + assert!(!s.doc().unwrap().is_remote(copy)); + healthy(&s); + let _ = std::fs::remove_dir_all(d); +} diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 98d3eff25..b9e490797 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -219,7 +219,9 @@ pub(super) fn cut(s: &mut Session, p: &Value) -> Result { delete(s, &json!({"ids": layers})) } -/// Paste the clipboard under `parent` with the copied top-left moved to `at` (page coords). +/// Paste the clipboard under `parent` with the copied top-left moved to `at` (page coords). A +/// copied main is pasted as an instance of it; in another file, as an instance of it from the +/// library the source file publishes, and as a copy of it when that library doesn't offer it. pub fn paste_into(s: &mut Session, parent: NodeId, at: Option<(f64, f64)>) -> Result> { paste_layers(s, parent, at, false) } @@ -250,13 +252,16 @@ fn paste_layers(s: &mut Session, parent: NodeId, at: Option<(f64, f64)>, as_vari let mut out = Vec::new(); let mut all = BTreeMap::new(); for (root, nodes) in &clip.nodes { - if copy_local - && !into_set - && clip.copied_components.contains(root) - && let Some(n) = nodes.first().filter(|n| matches!(n.kind, NodeKind::Component { .. })) - && doc.node(*root).is_some_and(|n| matches!(n.kind, NodeKind::Component { .. })) - { - let instance = crate::components::create_instance(doc, *root, parent, 0.0, 0.0)?; + let copied_main = nodes.first().filter(|n| clip.copied_components.contains(root) && matches!(n.kind, NodeKind::Component { .. })); + let main = match (copied_main, foreign) { + (Some(_), _) if copy_local => { + (!into_set && doc.node(*root).is_some_and(|n| matches!(n.kind, NodeKind::Component { .. }))).then_some(*root) + } + (Some(_), Some(src)) => crate::library::published_main(doc, src, clip.source_path.as_deref(), *root)?, + _ => None, + }; + if let (Some(main), Some(n)) = (main, copied_main) { + let instance = crate::components::create_instance(doc, main, parent, 0.0, 0.0)?; doc.get_mut(instance)?.transform = doc.world_transform(parent).inverse() * shift * n.transform; out.push(instance); continue; diff --git a/docs/components-parity.md b/docs/components-parity.md index b5df94b71..6d51e275e 100644 --- a/docs/components-parity.md +++ b/docs/components-parity.md @@ -1,6 +1,6 @@ # Components, variants, styles and variables parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (copied variants pasted with their own set, or a layer in it, selected join the set as new variants; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-23 · **Change:** minor (a main component copied from a library file and pasted into another file is an instance of it from that library, instead of a new main; copied variants pasted with their own set, or a layer in it, selected join the set as new variants; a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); components can't contain their own instances, directly or through others (#1084); the instance-swap menus have a search field (#1338); an instance-swap property's default menu scrolls (#1338); variables on a text style's fields from the style editor; instance-swap properties in the component playground; duplicating or Alt-dragging a main component makes an instance of it (#892); a bound colour variable's alpha applies once (#802); variables import reads `variables` outside `meta` and warns when it imports none (#790); variant properties reorder by drag; library files saved right after a read are read again; Hide when publishing note corrected; size and resizing overrides of layers inside instances (#731); variables export in the browser as a download; core editor leftovers: component playground, variables inside styles; layers and assets panels behaviour suite and fixes; extended collections tail; styles and variables behaviour suite and fixes; components behaviour suite and fixes; team libraries on the server, library usage and swapping a library; extended collections, variables import/export, gradient stops and variant properties bound to variables) · **Target:** Figma Design (desktop app 126.10.7) Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300 @@ -18,7 +18,7 @@ accounts). | What an instance overrides: fills, strokes, effects, visibility, layer names, text content and every text property (resizing included), auto layout padding, gap and alignment, layout grids, export settings, prototype interactions, nested swaps and property values; the size and resizing (hug, fill, fixed, min and max) of layers inside it; an instance's own resizing (hug or fixed) follows its main's unless its size is overridden, measured: a plain instance turns Fixed when its main does (a child set to Fill along the hugging axis) and back to Hug with it, one whose width was typed keeps it, and Fill in its own auto layout parent is its own | done | each kept when the main changes that property, reset per group; opacity and corner radius too (documentation silent); size and resizing are kept through relayout, undo, save, `.fig` and REST import and detach, and stay with the instance on push | | What it doesn't: position, rotation, constraints and absolute or grid placement of layers inside it, its auto layout direction and other settings, its structure | done | refused with a message, the fields greyed out (Delete on a layer inside an instance hides it instead of removing it, as the help center says it does); the instance itself resizes and its layers follow the main's constraints | | Component sets / variants, add variant, switch | done | Combine as variants is in the Object menu, and the canvas and layers context menu and the Design panel offer it when two or more main components are selected; Add variant on a main component not in a set yet makes it a set of itself and the new variant, one undo step (#903); components that are variants already aren't combined again (it used to put a set inside a set); combining gives every variant the component properties any of them had, so another variant's layers can be bound to one made before combining | -| A main's copy within its file is an instance of it: Duplicate, Alt-drag, Copy then Paste | done | a variant duplicated in its set stays a new variant and a whole set copies as a new set; only the copied roots become instances (a main inside a copied frame is copied as a main); Cut then Paste and pastes into other files keep the component (#892); copied variants pasted with their own set, or a variant or layer in it, selected join the set as new variants, while other pastes into a set, Paste over and Paste to replace still make an instance | +| A main's copy within its file is an instance of it: Duplicate, Alt-drag, Copy then Paste | done | a variant duplicated in its set stays a new variant and a whole set copies as a new set; only the copied roots become instances (a main inside a copied frame is copied as a main); Cut then Paste keeps the component (#892); pasted into another file, a main the source file publishes as a library is an instance of it from that library, which gets enabled, and any other main is a copy of itself; copied variants pasted with their own set, or a variant or layer in it, selected join the set as new variants, while other pastes into a set, Paste over and Paste to replace still make an instance | | A component can't contain its own instance, directly or through other components | done | refused with the loop named (creating, placing, swapping, switching variants, moving, pasting, an instance-swap value); each variant counts as its own component, so a variant may hold a sibling variant's instance unless that one leads back to it; a dropped instance lands on the page; a file holding a loop opens with one instance detached and a note, any other file unchanged; a loop merged in a live session stops expanding where an instance would show itself again (#1084) | | Switching variants keeps overrides where names match and both variants had the same value; text layers keep theirs | done | | | Default variant: the top-left one (new instances, Assets thumbnail, generated code) | done | | @@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`. | Date | Change | Summary | |---|---|---| +| 2026-11-23 | minor | M3: a main component copied from a library file and pasted into another file is an instance of it from that library, which gets enabled in that file, as pasting an instance of it already was and as Figma does with a published component. It used to paste a copy of the main, a new component of that file unlinked from the library. A variant pastes as an instance of that variant. A component the library doesn't offer (hidden from publishing, or added since the last publish) and a main from a file that publishes no library still paste as a copy. Test: `library::tests::a_main_pasted_from_its_library_file_is_an_instance_of_it`. Numbers unchanged | | 2026-11-19 | patch | M3: copying a variant and pasting with that variant, a layer in it or its set selected pasted an instance on the page. Copied variants of one set now paste into that set as new variants (deep copies, as Duplicate makes), under the copied variants where they are now, below the lowest variant with the gap of 20 that Add variant leaves, and the set grows to hold them. Every other paste of a copied main still makes an instance: with nothing selected, into another set, a main that isn't a variant pasted with a set selected, Paste over and Paste to replace on a variant, and an explicit `parent` (even the variant's own set). Tests: `pasting_a_variant_with_its_set_selected_adds_a_variant_below_the_others`, `a_variant_pasted_into_its_set_after_the_set_moved_lands_under_the_variant`, `a_variant_pasted_with_another_set_selected_is_an_instance`, `a_main_that_is_no_variant_pasted_with_a_set_selected_is_an_instance`, `a_variant_pasted_with_its_own_set_as_an_explicit_parent_is_an_instance`, `pasting_over_or_replacing_a_variant_makes_an_instance_of_the_copied_variant` | | 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`::S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. | | 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. | diff --git a/docs/mcp.md b/docs/mcp.md index c1f3992a9..aedab7c3d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1057,6 +1057,8 @@ name and sets them this way); same library, components the other file publishes as a library are used from it (and that library is enabled when the other file is saved), and other mains stay behind: the instance shows a missing main (`component.restoreMain` makes it a main here). + A main component copied from a file that publishes it as a library pastes as an instance of + it from that library (enabled the same way); a main that library doesn't offer pastes as a copy. ### Team libraries diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 409efe1d7..c7d1b74c3 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -371,7 +371,8 @@ Hours in this narrative are the builders' estimates; the tables above supersede Instance swap properties have preferred values (offered first). Alt-drop from the Assets panel onto an instance swaps it (same-set instance preferred, highlighted while dragging); instances pasted into other files follow their mains (library copies shared, published components used - from their library, other mains left behind as a restorable missing main). The Assets panel lays + from their library, other mains left behind as a restorable missing main), and a main pasted + from its library file is an instance of it from that library. The Assets panel lays out only the tiles in view and renders thumbnails as they show (cached, re-rendered only for changed components). A behaviour suite from the public documentation checks overrides (what an instance takes, what it refuses: geometry, constraints and resizing of its layers, its auto From f9964e14ae1aeca1a83cc04a204208d2abbf9c4f Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Fri, 20 Nov 2026 23:04:14 -0500 Subject: [PATCH 19/36] Desktop: reopen the files open at quit instead of starting in a new file The desktop app started in a new, empty file on every launch, and with a control port open (FIGCRAFT_CONTROL_PORT set for an attached agent) even the Start on the Home screen preference was overridden, so the files you worked in had to be found and opened again each time. Quitting now keeps the paths of the open tabs' files, in tab order, and the one in front (Prefs::open_files, Prefs::front_file); the next start opens them again and brings that one forward, as Figma's desktop app reopens its tabs. Files without a path (new, imported, joined live) and branch tabs are left out. A file named on the command line stays in front, a recovered copy keeps its one tab (file.open switches to an open path), a file gone since is skipped, and one that won't open is reported like a file named on the command line. With nothing to reopen the window starts on the Home screen; only with a control port open does it still start in a new file (#874: control callers expect a document). Start on the Home screen now means Home instead of the reopened files. The list is written at quit only, with the other preferences. Keeping it on every tab change would cover a crash too, but a crash already brings back the unsaved files through recovery copies, and the list from the last quit is a fair fallback for the rest. --- apps/figcraft/src/main.rs | 55 +++++++++++----- apps/figcraft/src/services.rs | 4 +- crates/engine/src/lib.rs | 3 + crates/engine/src/prefs.rs | 12 +++- crates/engine/src/reopen.rs | 38 +++++++++++ crates/engine/src/reopen_tests.rs | 103 ++++++++++++++++++++++++++++++ docs/mcp.md | 7 +- docs/ui-parity.md | 3 +- 8 files changed, 204 insertions(+), 21 deletions(-) create mode 100644 crates/engine/src/reopen.rs create mode 100644 crates/engine/src/reopen_tests.rs diff --git a/apps/figcraft/src/main.rs b/apps/figcraft/src/main.rs index 1d24e511b..b340fcbdd 100644 --- a/apps/figcraft/src/main.rs +++ b/apps/figcraft/src/main.rs @@ -209,7 +209,7 @@ fn main() -> eframe::Result { failed_open = Some(format!("{name}: {e}")); } } - let opened: Vec = session.docs.iter().map(|d| d.uid).collect(); + let mut opened: Vec = session.docs.iter().map(|d| d.uid).collect(); // Documents a crashed or killed run left unsaved come back; this run keeps its own copies. let recovery_root = services::config_dir().map(|d| d.join("Recovery")); // The preferences first: they hold the online files a recovered document may be one of. @@ -233,7 +233,20 @@ fn main() -> eframe::Result { session.live.links = figcraft_collab_net::links::system(); session.invite_links_startup(); let first_run = svc.prefs.is_none() && args.join.is_none(); - if session.docs.is_empty() && opens_new_file(first_run, session.prefs.start_on_home, port.is_some()) { + if reopens_files(first_run, session.prefs.start_on_home) { + let before: Vec = session.docs.iter().map(|d| d.uid).collect(); + for (path, e) in session.reopen_files() { + log::error!("{path}: {e}"); + let name = std::path::Path::new(&path).file_name().map_or_else(|| path.clone(), |n| n.to_string_lossy().into_owned()); + failed_open = Some(format!("{name}: {e}")); + } + // A file named on the command line stays in front. + if let Some(i) = opened.last().and_then(|uid| session.docs.iter().position(|d| d.uid == *uid)) { + session.active = i; + } + opened.extend(session.docs.iter().map(|d| d.uid).filter(|u| !before.contains(u))); + } + if session.docs.is_empty() && opens_new_file(first_run, port.is_some()) { let _ = session.execute("file.new", &json!({})); } // The interface language from the first frame on, and for the message when the window can't @@ -243,7 +256,8 @@ fn main() -> eframe::Result { fig.set_startup_update_check(true); fig.automation_roots = roots; fig.ui.home = false; - // Files named on the command line are the user's too: their missing fonts are listed. + // Files named on the command line or reopened are the user's too: their missing fonts are + // listed. fig.ui.font_checks = opened; fig.note_recovered(recovered.copies); if let Some(message) = failed_open { @@ -325,12 +339,17 @@ fn main() -> eframe::Result { graphics.finish(result, frames, port.is_some()) } -/// With nothing to open, whether the window starts in a new file rather than on the home screen. -/// A first run (no settings kept yet) shows the home screen's tips and templates, and later runs -/// start in a new file unless the preference asks for Home, which `--control` overrides: its -/// callers expect a document to act on. -fn opens_new_file(first_run: bool, start_on_home: bool, control: bool) -> bool { - !first_run && (!start_on_home || control) +/// Whether the files open when the app last quit open again: not on a first run (no settings kept +/// yet), nor when the preference asks for the Home screen. +fn reopens_files(first_run: bool, start_on_home: bool) -> bool { + !first_run && !start_on_home +} + +/// With nothing open, whether the window starts in a new file rather than on the home screen: only +/// with a control port open (`--control`), whose callers expect a document to act on. A first run +/// shows the home screen's tips and templates whatever the port. +fn opens_new_file(first_run: bool, control: bool) -> bool { + !first_run && control } /// The title bar FigCraft starts with, decided by the shared craft-window crate so every Craft app @@ -426,13 +445,19 @@ mod title_bar_tests { #[cfg(test)] mod start_tests { - use super::opens_new_file; + use super::{opens_new_file, reopens_files}; #[test] - fn the_home_preference_starts_on_home_except_for_control_callers() { - assert!(opens_new_file(false, false, false), "a new file by default"); - assert!(!opens_new_file(false, true, false), "Home when the preference asks"); - assert!(opens_new_file(false, true, true), "--control still starts with a document"); - assert!(!opens_new_file(true, false, false), "a first run shows the home screen"); + fn the_last_files_reopen_unless_the_home_preference_asks_or_on_a_first_run() { + assert!(reopens_files(false, false), "by default"); + assert!(!reopens_files(false, true), "Home when the preference asks"); + assert!(!reopens_files(true, false), "a first run has nothing to reopen"); + } + + #[test] + fn with_nothing_open_only_control_callers_start_in_a_new_file() { + assert!(!opens_new_file(false, false), "the home screen, not an empty file"); + assert!(opens_new_file(false, true), "--control starts with a document"); + assert!(!opens_new_file(true, true), "a first run shows the home screen"); } } diff --git a/apps/figcraft/src/services.rs b/apps/figcraft/src/services.rs index 0f2363773..5fd30c35e 100644 --- a/apps/figcraft/src/services.rs +++ b/apps/figcraft/src/services.rs @@ -348,9 +348,11 @@ fn open_directory(file: &std::fs::File) -> Result<(), String> { const STATE: &str = "state.json"; /// Everything quitting keeps, all done when it returns (macOS then ends the process): the -/// preferences in `dir`, this run's recovery copies ([`Recovery::quit`](crate::recovery::Recovery::quit)) +/// preferences in `dir` with the files open now, which the next start reopens, this run's recovery +/// copies ([`Recovery::quit`](crate::recovery::Recovery::quit)) /// and the live sessions' ends (one this app hosts tells everyone and stops; a joined one leaves). pub fn shutdown(app: &mut FigApp, dir: Option<&Path>, recovery: Option) { + app.session.remember_open_files(); if let Some(dir) = dir { write_prefs(dir, &app.session.prefs); } diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ad6bb085e..3220e6326 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -106,6 +106,7 @@ mod derived; mod doc_state; mod error; mod prefs; +mod reopen; mod session; mod view_state; @@ -543,6 +544,8 @@ mod proto_run_tests; #[cfg(test)] mod proto_tail_tests; #[cfg(test)] +mod reopen_tests; +#[cfg(test)] mod rest_slot_tests; #[cfg(test)] mod retained_walk_tests; diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 4225963f5..182c20f00 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -63,7 +63,8 @@ pub struct Prefs { /// Files that have a path are saved by themselves a few seconds after they change (the app's /// timer; off: only File ▸ Save writes them). pub auto_save: bool, - /// The desktop app starts on the Home screen instead of in a new file. + /// The desktop app starts on the Home screen instead of reopening the files open when it last + /// quit. pub start_on_home: bool, /// `figcraft://` invite links open this app (`collab.registerLinks`); `None`: on for installed /// builds, off for development builds. @@ -85,6 +86,13 @@ pub struct Prefs { /// Recently opened or saved files, newest first (File ▸ Open recent; at most /// [`cmd::file::MAX_RECENT`]). pub recent_files: Vec, + /// The files open when the desktop app last quit, in tab order: the next start opens them again + /// ([`Session::reopen_files`](crate::Session::reopen_files)). + #[serde(skip_serializing_if = "Vec::is_empty")] + pub open_files: Vec, + /// Which of [`open_files`](Self::open_files) was in front. + #[serde(skip_serializing_if = "Option::is_none")] + pub front_file: Option, /// The files you put on a server without its key, with their owner tokens (passwords: see /// [`online`]), most recently opened first, at most [`online::MAX_ONLINE_FILES`]. #[serde(skip_serializing_if = "Vec::is_empty", deserialize_with = "online::read")] @@ -155,6 +163,8 @@ impl Default for Prefs { plugin_directory: None, publish_server: live::DEFAULT_SERVER.into(), recent_files: Vec::new(), + open_files: Vec::new(), + front_file: None, online_files: Vec::new(), getting_started_dismissed: false, link_notice_skipped: false, diff --git a/crates/engine/src/reopen.rs b/crates/engine/src/reopen.rs new file mode 100644 index 000000000..b2f7fdeb5 --- /dev/null +++ b/crates/engine/src/reopen.rs @@ -0,0 +1,38 @@ +//! The files open when the desktop app quit open again at its next start, in their tabs' order +//! with the same one in front, as Figma's desktop app reopens its tabs. + +use serde_json::json; + +use crate::{EngineError, Session}; + +impl Session { + /// Keep the open files to reopen at the next start: each tab's file that has a path, in tab + /// order, and the one in front. Files without one (new, imported, joined from a live session) + /// and branch tabs are left out. + pub fn remember_open_files(&mut self) { + let path = |i: usize| self.docs.get(i).filter(|d| d.branch_of.is_none()).and_then(|d| d.path.clone()); + self.prefs.open_files = (0..self.docs.len()).filter_map(path).collect(); + self.prefs.front_file = path(self.active); + } + + /// Open the files [`remember_open_files`](Self::remember_open_files) kept, then bring the one + /// that was in front forward. A file that is no longer there is skipped; the others that don't + /// open come back with why. A file already open (a recovered copy, one named at start) keeps + /// its tab. + pub fn reopen_files(&mut self) -> Vec<(String, EngineError)> { + let mut failed = Vec::new(); + for path in self.prefs.open_files.clone() { + if !crate::file_access::exists(&path) { + continue; + } + if let Err(e) = self.execute("file.open", &json!({"path": path})) { + failed.push((path, e)); + } + } + let front = self.prefs.front_file.as_deref(); + if let Some(i) = self.docs.iter().position(|d| front.is_some() && d.path.as_deref() == front) { + self.active = i; + } + failed + } +} diff --git a/crates/engine/src/reopen_tests.rs b/crates/engine/src/reopen_tests.rs new file mode 100644 index 000000000..b02c95c90 --- /dev/null +++ b/crates/engine/src/reopen_tests.rs @@ -0,0 +1,103 @@ +//! The files open when the desktop app quit open again at its next start. + +use std::path::PathBuf; + +use serde_json::json; + +use crate::Session; + +fn folder(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("figcraft-reopen-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + dir +} + +fn saved(s: &mut Session, dir: &std::path::Path, name: &str) -> String { + let path = dir.join(format!("{name}.figcraft")).to_string_lossy().into_owned(); + s.execute("file.new", &json!({"name": name})).unwrap(); + s.execute("file.save", &json!({"path": path})).unwrap(); + path +} + +fn paths(s: &Session) -> Vec> { + s.docs.iter().map(|d| d.path.clone()).collect() +} + +/// The next start: the preferences the last run kept, nothing open yet. +fn next_start(last: &Session) -> Session { + let mut s = Session::empty(); + s.prefs = last.prefs.clone(); + s +} + +#[test] +fn the_files_open_at_quit_reopen_in_their_order_with_the_same_one_in_front() { + let dir = folder("order"); + let mut s = Session::empty(); + let a = saved(&mut s, &dir, "A"); + s.execute("file.new", &json!({"name": "Untitled"})).unwrap(); + let b = saved(&mut s, &dir, "B"); + let c = saved(&mut s, &dir, "C"); + s.execute("doc.switch", &json!({"index": 2})).unwrap(); + s.remember_open_files(); + assert_eq!(s.prefs.open_files, vec![a.clone(), b.clone(), c.clone()], "the new file without a path is left out"); + assert_eq!(s.prefs.front_file.as_deref(), Some(b.as_str())); + + let mut t = next_start(&s); + assert!(t.reopen_files().is_empty()); + assert_eq!(paths(&t), vec![Some(a), Some(b.clone()), Some(c)]); + assert_eq!(t.docs[t.active].path.as_deref(), Some(b.as_str()), "B is in front again"); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn a_file_gone_since_is_skipped_and_one_that_wont_open_says_why() { + let dir = folder("gone"); + let mut s = Session::empty(); + let kept = saved(&mut s, &dir, "Kept"); + let gone = saved(&mut s, &dir, "Gone"); + let broken = saved(&mut s, &dir, "Broken"); + s.remember_open_files(); + std::fs::remove_file(&gone).unwrap(); + std::fs::write(&broken, b"not a figcraft file").unwrap(); + + let mut t = next_start(&s); + let failed = t.reopen_files(); + assert_eq!(failed.iter().map(|(p, _)| p.clone()).collect::>(), vec![broken]); + assert_eq!(paths(&t), vec![Some(kept)]); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn a_file_already_open_at_start_keeps_its_one_tab() { + let dir = folder("twice"); + let mut s = Session::empty(); + let a = saved(&mut s, &dir, "A"); + let b = saved(&mut s, &dir, "B"); + s.execute("doc.switch", &json!({"index": 0})).unwrap(); + s.remember_open_files(); + + // B was named on the command line (or came back as a recovered copy). + let mut t = next_start(&s); + t.execute("file.open", &json!({"path": b})).unwrap(); + assert!(t.reopen_files().is_empty()); + assert_eq!(paths(&t), vec![Some(b), Some(a.clone())]); + assert_eq!(t.docs[t.active].path.as_deref(), Some(a.as_str())); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn quitting_with_nothing_open_leaves_nothing_to_reopen() { + let dir = folder("none"); + let mut s = Session::empty(); + saved(&mut s, &dir, "A"); + s.remember_open_files(); + s.execute("file.close", &json!({"index": 0})).unwrap(); + s.remember_open_files(); + assert!(s.prefs.open_files.is_empty()); + assert_eq!(s.prefs.front_file, None); + let saved = serde_json::to_value(&s.prefs).unwrap(); + assert!(saved.get("open_files").is_none() && saved.get("front_file").is_none(), "not written when empty"); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/docs/mcp.md b/docs/mcp.md index c1f3992a9..031b2d2ba 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -790,9 +790,10 @@ on; `key` resolves keys the way the canvas does. Commands behind keys: it is larger; the choice is kept. In the browser the interface always follows the browser's zoom. - `pref.autoSave {on?}`: files that have a path save themselves a few seconds after they change (off by default; the desktop app's timer does it, so scripts still call `file.save`). -- `pref.startOnHome {on?}`: the desktop app starts on the Home screen instead of in a new file - (off by default; files named on the command line still open, and `--control` starts in a new - file anyway, so control callers have a document). +- `pref.startOnHome {on?}`: the desktop app starts on the Home screen instead of reopening the + files open when it last quit (off by default; with nothing to reopen it starts on the Home screen + too; files named on the command line still open, and with nothing open `--control` starts in a new + file, so control callers have a document). - `pref.language {language: system|en|bs|cs|ru|es|es-419|fr|de|pt-BR|ja|ka|ko|sv|vi|zh-Hans|zh-Hant|…}`: the app's interface language, applied live ("system": the OS or browser language; a language without a catalog shows English). Command ids, labels and every result stay English. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..6e5cc17d7 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** minor (the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-20 | patch | The desktop app started in a new, empty file every time, whatever was open when it quit. It now opens those files again, in their tabs' order with the same one in front, as Figma's desktop app reopens its tabs; quitting keeps their paths with the preferences (files without one, such as new or imported files, and branch tabs are left out). A file named on the command line still opens and stays in front, a recovered copy keeps its one tab, a file gone since is skipped and one that won't open says why. With nothing to reopen the app starts on the Home screen; with a control port open (`--control`) it still starts in a new file, so control callers have a document. Preferences ▸ Start on the Home screen starts there instead of reopening the files. Tests: `reopen_tests` (4), `start_tests` (2). Numbers unchanged | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 6247922621bd58188da840eaeadebce5741d6395 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:04:55 -0500 Subject: [PATCH 20/36] M5: a file opens again where it was left A file always opened on the page saved in it, fitted to its content, so coming back to a file meant finding the place again. Figma opens a file where you were. Closing a file's tab or quitting now keeps the page it showed and each page's view (centre and zoom) in the preferences, by path, for the last 100 files left. Opening the file shows that page at its view, and the canvas keeps the view instead of fitting the page when it first gets its size (DocState::fit_when_sized). A page the file no longer has, a divider or a view the canvas can't show is left out. Keeping the view in the file was rejected: it would come back only after a save, and looking around would make the file unsaved. The preferences are per machine, so another computer opens the file fitted. --- apps/figcraft/src/services.rs | 5 +- crates/engine/src/cmd/file.rs | 1 + crates/engine/src/cmd/file/open.rs | 1 + crates/engine/src/doc_state.rs | 27 ++++++ crates/engine/src/file_views.rs | 74 ++++++++++++++++ crates/engine/src/file_views/tests.rs | 123 ++++++++++++++++++++++++++ crates/engine/src/lib.rs | 2 + crates/engine/src/prefs.rs | 6 ++ crates/ui-egui/src/canvas.rs | 2 +- docs/ui-parity.md | 5 +- 10 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 crates/engine/src/file_views.rs create mode 100644 crates/engine/src/file_views/tests.rs diff --git a/apps/figcraft/src/services.rs b/apps/figcraft/src/services.rs index 5fd30c35e..93635e02b 100644 --- a/apps/figcraft/src/services.rs +++ b/apps/figcraft/src/services.rs @@ -348,11 +348,12 @@ fn open_directory(file: &std::fs::File) -> Result<(), String> { const STATE: &str = "state.json"; /// Everything quitting keeps, all done when it returns (macOS then ends the process): the -/// preferences in `dir` with the files open now, which the next start reopens, this run's recovery -/// copies ([`Recovery::quit`](crate::recovery::Recovery::quit)) +/// preferences in `dir` with the files open now, which the next start reopens, and where each was +/// left, this run's recovery copies ([`Recovery::quit`](crate::recovery::Recovery::quit)) /// and the live sessions' ends (one this app hosts tells everyone and stops; a joined one leaves). pub fn shutdown(app: &mut FigApp, dir: Option<&Path>, recovery: Option) { app.session.remember_open_files(); + app.session.remember_views(); if let Some(dir) = dir { write_prefs(dir, &app.session.prefs); } diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs index 0c84f3458..a108239f2 100644 --- a/crates/engine/src/cmd/file.rs +++ b/crates/engine/src/cmd/file.rs @@ -462,6 +462,7 @@ fn close(s: &mut Session, p: &Value) -> Result { } let uid = ds.uid; let active_uid = s.docs.get(s.active).map(|d| d.uid); + s.remember_view(i); s.remove_tabs(|d| d.uid == uid); // Removing a tab before the active one shifts its index; keep the same document selected. s.active = active_uid.and_then(|a| s.docs.iter().position(|d| d.uid == a)).unwrap_or(i.min(s.docs.len().saturating_sub(1))); diff --git a/crates/engine/src/cmd/file/open.rs b/crates/engine/src/cmd/file/open.rs index ea9a0d90a..dbb38f6c6 100644 --- a/crates/engine/src/cmd/file/open.rs +++ b/crates/engine/src/cmd/file/open.rs @@ -107,6 +107,7 @@ pub(crate) fn open(s: &mut Session, p: &Value) -> Result { ds.on_disk = on_disk.filter(|_| native); s.docs.push(ds); s.active = s.docs.len() - 1; + s.restore_view(); let mut out = json!({"index": s.active, "summary": summary}); out[if warnings { "warnings" } else { "repairs" }] = json!(loaded.issues); Ok(out) diff --git a/crates/engine/src/doc_state.rs b/crates/engine/src/doc_state.rs index 12dfefe32..5172fbdae 100644 --- a/crates/engine/src/doc_state.rs +++ b/crates/engine/src/doc_state.rs @@ -119,6 +119,9 @@ pub struct DocState { /// Where each page's view was left in this session (its centre and zoom; see /// [`Self::open_page`]; not saved). page_views: BTreeMap, + /// The canvas fits the page's content when it first gets its size. Off when the view was + /// restored from where the file was left ([`Session::restore_view`]). + pub fit_when_sized: bool, } /// A version shown on the canvas in place of the document: read-only until it's restored or the @@ -184,6 +187,7 @@ impl DocState { images_left_in_file: None, on_disk: None, page_views: BTreeMap::new(), + fit_when_sized: true, }; st.zoom_to_fit(); st @@ -332,6 +336,29 @@ impl DocState { } } + /// Each page's view as left: the one shown now at its current view, the others shown in this + /// session at theirs. + pub(crate) fn page_views(&self) -> impl Iterator + '_ { + let shown = (self.page, (self.view.cx, self.view.cy, self.view.zoom)); + self.page_views.iter().filter(|(p, _)| **p != self.page).map(|(p, v)| (*p, *v)).chain(std::iter::once(shown)) + } + + /// Take `views` as where their pages were left, and show `page` (or the page shown now) at + /// its view. With one, the canvas keeps it instead of fitting the page when it gets its size. + pub(crate) fn show_views(&mut self, page: Option, views: impl IntoIterator) { + self.page_views.extend(views); + if let Some(page) = page { + self.page = page; + } + match self.page_views.get(&self.page) { + Some(&(cx, cy, zoom)) => { + (self.view.cx, self.view.cy, self.view.zoom) = (cx, cy, zoom); + self.fit_when_sized = false; + } + None => self.zoom_to_fit(), + } + } + pub fn zoom_to_fit(&mut self) { match self.doc.page_content_bounds(self.page) { Some(b) => self.view.fit(b, 1.0), diff --git a/crates/engine/src/file_views.rs b/crates/engine/src/file_views.rs new file mode 100644 index 000000000..e7f55e9b1 --- /dev/null +++ b/crates/engine/src/file_views.rs @@ -0,0 +1,74 @@ +//! Files open again where they were left: when a file's tab closes or the app quits, the page it +//! showed and each page's view (its centre and zoom) are kept for that file, and opening it again +//! shows them, as Figma opens a file where you were. They live in the preferences, not in the +//! file, so looking around never changes a file. + +use serde::{Deserialize, Serialize}; + +use crate::{NodeId, Session, ViewState}; + +/// How many files' views are kept, the most recently left first. +pub const MAX_FILE_VIEWS: usize = 100; + +/// Where a file was left. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct FileView { + pub path: String, + /// The page shown. + pub page: NodeId, + /// The view of each page shown while it was open. + pub pages: Vec, +} + +/// A page's view: the page point at the canvas's centre, and the zoom. +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageView { + pub page: NodeId, + pub cx: f64, + pub cy: f64, + pub zoom: f64, +} + +impl Session { + /// Keep where tab `i`'s file is left. A tab without a file of its own (a new or imported file, + /// a branch) keeps nothing. + pub(crate) fn remember_view(&mut self, i: usize) { + let Some(ds) = self.docs.get(i).filter(|d| d.branch_of.is_none()) else { return }; + let Some(path) = ds.path.clone() else { return }; + let pages = ds.page_views().map(|(page, (cx, cy, zoom))| PageView { page, cx, cy, zoom }).collect(); + let view = FileView { path, page: ds.page, pages }; + let views = &mut self.prefs.file_views; + views.retain(|v| v.path != view.path); + views.insert(0, view); + views.truncate(MAX_FILE_VIEWS); + self.prefs_unsaved = true; + } + + /// [`remember_view`](Self::remember_view) for every open tab, before the app quits. + pub fn remember_views(&mut self) { + for i in 0..self.docs.len() { + self.remember_view(i); + } + } + + /// Show the active tab's file where it was left, if it was: its page, if the file still has + /// it as a page that isn't a divider, at its view, and each other page at its view when it is + /// shown. A view that isn't a finite centre with a zoom the canvas takes is left out. + pub(crate) fn restore_view(&mut self) { + let Ok(ds) = self.ds() else { return }; + let Some(kept) = ds.path.as_deref().and_then(|p| self.prefs.file_views.iter().find(|v| v.path == p)).cloned() else { return }; + let Ok(ds) = self.ds_mut() else { return }; + let doc = ds.doc.clone(); + let views = kept + .pages + .iter() + .filter(|v| doc.pages.contains(&v.page) && [v.cx, v.cy, v.zoom].iter().all(|x| x.is_finite())) + .filter(|v| (ViewState::MIN_ZOOM..=ViewState::MAX_ZOOM).contains(&v.zoom)) + .map(|v| (v.page, (v.cx, v.cy, v.zoom))); + let page = Some(kept.page).filter(|p| doc.pages.contains(p) && !doc.is_divider(*p)); + ds.show_views(page, views); + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/engine/src/file_views/tests.rs b/crates/engine/src/file_views/tests.rs new file mode 100644 index 000000000..1606c02ed --- /dev/null +++ b/crates/engine/src/file_views/tests.rs @@ -0,0 +1,123 @@ +//! Files open again where they were left. + +use serde_json::{Value, json}; + +use super::*; + +fn ex(s: &mut Session, cmd: &str, p: Value) -> Value { + s.execute(cmd, &p).unwrap_or_else(|e| panic!("{cmd} {p}: {e}")) +} + +fn dir(name: &str) -> std::path::PathBuf { + let d = std::env::temp_dir().join(format!("figcraft-file-views-{}-{name}", std::process::id())); + std::fs::create_dir_all(&d).unwrap(); + d +} + +/// A saved file at `path` with two pages, each holding a rectangle, the first page shown. +fn two_pages(s: &mut Session, path: &str) -> (NodeId, NodeId) { + ex(s, "file.new", json!({})); + ex(s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 100, "height": 100})); + ex(s, "page.add", json!({"name": "Second"})); + let pages = s.doc().unwrap().pages.clone(); + ex(s, "page.select", json!({"id": pages[1].0})); + ex(s, "shape.rectangle", json!({"x": 2000, "y": 2000, "width": 50, "height": 50})); + ex(s, "page.select", json!({"id": pages[0].0})); + ex(s, "file.saveAs", json!({"path": path})); + (pages[0], pages[1]) +} + +fn view(s: &Session) -> (NodeId, f64, f64, f64) { + let ds = s.ds().unwrap(); + (ds.page, ds.view.cx, ds.view.cy, ds.view.zoom) +} + +fn look(s: &mut Session, cx: f64, cy: f64, zoom: f64) { + let v = &mut s.ds_mut().unwrap().view; + (v.cx, v.cy, v.zoom) = (cx, cy, zoom); +} + +/// Closed and opened again, a file shows the page it showed, at its view, and its other page at +/// the view that page was left at; looking around leaves the file unchanged. +#[test] +fn a_file_opens_again_where_it_was_left() { + let d = dir("left"); + let path = d.join("two.figcraft").to_string_lossy().into_owned(); + let mut s = Session::new(); + let (first, second) = two_pages(&mut s, &path); + let saved = std::fs::read(&path).unwrap(); + look(&mut s, 40.0, 60.0, 2.5); + ex(&mut s, "page.select", json!({"id": second.0})); + look(&mut s, 2010.0, 2020.0, 0.5); + assert!(!s.ds().unwrap().is_dirty(), "looking around is no change to the file"); + ex(&mut s, "file.close", json!({})); + assert_eq!(std::fs::read(&path).unwrap(), saved, "nothing written to the file"); + assert!(s.prefs_unsaved, "kept in the preferences"); + ex(&mut s, "file.open", json!({"path": path})); + assert_eq!(view(&s), (second, 2010.0, 2020.0, 0.5)); + assert!(!s.ds().unwrap().fit_when_sized, "the canvas keeps the view instead of fitting"); + ex(&mut s, "page.select", json!({"id": first.0})); + assert_eq!(view(&s), (first, 40.0, 60.0, 2.5)); + // Through the preferences file, as the next start reads them. + let prefs: crate::Prefs = serde_json::from_value(serde_json::to_value(&s.prefs).unwrap()).unwrap(); + let mut next = Session::new(); + next.prefs = prefs; + ex(&mut next, "file.open", json!({"path": path})); + assert_eq!(view(&next), (second, 2010.0, 2020.0, 0.5)); + let _ = std::fs::remove_dir_all(d); +} + +/// Quitting keeps every open file's view; a file never saved keeps none. +#[test] +fn quitting_keeps_each_open_files_view() { + let d = dir("quit"); + let (a, b) = (d.join("a.figcraft").to_string_lossy().into_owned(), d.join("b.figcraft").to_string_lossy().into_owned()); + let mut s = Session::new(); + let (a_page, _) = two_pages(&mut s, &a); + look(&mut s, 1.0, 2.0, 3.0); + let (b_page, _) = two_pages(&mut s, &b); + look(&mut s, 4.0, 5.0, 0.25); + ex(&mut s, "file.new", json!({})); + s.remember_views(); + let kept: Vec<&str> = s.prefs.file_views.iter().map(|v| v.path.as_str()).collect(); + assert_eq!(kept.len(), 2, "{kept:?}"); + let mut next = Session::new(); + next.prefs = s.prefs.clone(); + ex(&mut next, "file.open", json!({"path": a})); + assert_eq!(view(&next), (a_page, 1.0, 2.0, 3.0)); + ex(&mut next, "file.open", json!({"path": b})); + assert_eq!(view(&next), (b_page, 4.0, 5.0, 0.25)); + let _ = std::fs::remove_dir_all(d); +} + +/// A kept page the file no longer has, or a view the canvas can't show, is left out: the file +/// opens fitted as before. +#[test] +fn a_view_that_no_longer_fits_the_file_is_left_out() { + let d = dir("stale"); + let path = d.join("one.figcraft").to_string_lossy().into_owned(); + let mut s = Session::new(); + let (first, _) = two_pages(&mut s, &path); + ex(&mut s, "file.close", json!({})); + s.prefs.file_views[0].page = NodeId(999_999); + s.prefs.file_views[0].pages = vec![PageView { page: first, cx: f64::NAN, cy: 0.0, zoom: 1.0 }]; + ex(&mut s, "file.open", json!({"path": path})); + let ds = s.ds().unwrap(); + assert_eq!(ds.page, first); + assert!(ds.fit_when_sized, "fitted as a file never left"); + assert!(ds.view.cx.is_finite()); + let _ = std::fs::remove_dir_all(d); +} + +/// The views kept are bounded, the most recently left first. +#[test] +fn the_most_recently_left_files_are_kept() { + let mut s = Session::new(); + for k in 0..MAX_FILE_VIEWS + 5 { + ex(&mut s, "file.new", json!({})); + s.ds_mut().unwrap().path = Some(format!("/nowhere/{k}.figcraft")); + ex(&mut s, "file.close", json!({"force": true})); + } + assert_eq!(s.prefs.file_views.len(), MAX_FILE_VIEWS); + assert_eq!(s.prefs.file_views[0].path, format!("/nowhere/{}.figcraft", MAX_FILE_VIEWS + 4)); +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 3220e6326..fac2cc122 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -105,6 +105,7 @@ use serde_json::{Value, json}; mod derived; mod doc_state; mod error; +mod file_views; mod prefs; mod reopen; mod session; @@ -113,6 +114,7 @@ mod view_state; pub use derived::{changed_nodes, normalize}; pub use doc_state::{DocState, History, HistoryEntry, Interaction, PREVIEW_READ_ONLY, Preedit, TextEdit, VersionPreview}; pub use error::{EngineError, Result, bad}; +pub use file_views::{FileView, MAX_FILE_VIEWS, PageView}; pub use prefs::{Clipboard, DefaultProps, MAX_RECENT_ACTIONS, Prefs, UI_SCALE_MAX, UI_SCALE_MIN, UI_SCALE_SIZES, UiRequest, clamp_ui_scale}; pub use session::Forward; pub use view_state::ViewState; diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 182c20f00..fb5f5d412 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -93,6 +93,11 @@ pub struct Prefs { /// Which of [`open_files`](Self::open_files) was in front. #[serde(skip_serializing_if = "Option::is_none")] pub front_file: Option, + /// Where each file was left when its tab closed or the app quit, the most recently left first, + /// at most [`MAX_FILE_VIEWS`](crate::MAX_FILE_VIEWS): opening it again shows that page at that + /// view ([`Session::remember_views`](crate::Session::remember_views)). + #[serde(skip_serializing_if = "Vec::is_empty")] + pub file_views: Vec, /// The files you put on a server without its key, with their owner tokens (passwords: see /// [`online`]), most recently opened first, at most [`online::MAX_ONLINE_FILES`]. #[serde(skip_serializing_if = "Vec::is_empty", deserialize_with = "online::read")] @@ -165,6 +170,7 @@ impl Default for Prefs { recent_files: Vec::new(), open_files: Vec::new(), front_file: None, + file_views: Vec::new(), online_files: Vec::new(), getting_started_dismissed: false, link_notice_skipped: false, diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 3d3f05082..140351a11 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -272,7 +272,7 @@ pub fn show(app: &mut FigApp, ui: &mut Ui, worker: &mut Worker) { // Otherwise keep the centre. ds.view.vw = f64::from(rect.width()); ds.view.vh = f64::from(rect.height()); - if first { + if first && ds.fit_when_sized { ds.zoom_to_fit(); } } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 6e5cc17d7..31dc52259 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** minor (the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (a file opens again on the page and at the view it was left at; the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -113,7 +113,7 @@ interaction feel only partly compared: the interactions measured so far, case by | Item | Status | Notes | |---|---|---| -| Pan/zoom: wheel, pinch, Space-drag, Shift+0/1/2, Cmd+0, `+`/`-` | done | Shift-wheel pans sideways, pinch and the zoom tool keep the point under the pointer; Preferences ▸ Scroll wheel zoom makes a mouse wheel zoom about the pointer and Cmd/Ctrl+wheel scroll (a wheel told from a trackpad by the device macOS reports, elsewhere by line versus pixel steps; #1390); the arrows pan the view with nothing selected by 64 px, 320 px (five steps) with Shift (`view.pan`; measured in Figma's web app at 100% zoom: one Right press 62–64 px in two trials, Shift+Right about 320 px, reading offsets from screenshots, about ±3 px); Preferences ▸ Invert zoom direction (Figma's Preferences menu has it, checked 2026-11-09; #2145) reverses wheel zoom: Cmd/Ctrl+wheel, and a plain mouse wheel with Scroll wheel zoom on, zoom out where they would zoom in, by the same factor, while a trackpad pinch and panning are unchanged (only the setting's existence was measured, so the pinch is left alone); zoom steps, limits (2%–25,600%) and frame order pinned where the documentation is silent (`view_behaviour_tests`); Zoom to selection (Shift+2) fits the selection into the canvas above the floating bottom toolbar with a 40 pt margin on all four sides, centred in that area, at a continuous zoom (measured in Figma's web app, 2026-11-09; `zoom_to_selection_leaves_forty_points_and_clears_the_toolbar`, `zoom_to_selection_on_a_wide_layer_is_limited_by_the_width`, `zoom_to_selection_without_a_toolbar_inset_uses_the_whole_height`); Zoom to fit (Shift+1) keeps its 64 pt margin, margin not measured yet (`zoom_to_fit_is_unchanged`) | +| Pan/zoom: wheel, pinch, Space-drag, Shift+0/1/2, Cmd+0, `+`/`-` | done | Shift-wheel pans sideways, pinch and the zoom tool keep the point under the pointer; Preferences ▸ Scroll wheel zoom makes a mouse wheel zoom about the pointer and Cmd/Ctrl+wheel scroll (a wheel told from a trackpad by the device macOS reports, elsewhere by line versus pixel steps; #1390); the arrows pan the view with nothing selected by 64 px, 320 px (five steps) with Shift (`view.pan`; measured in Figma's web app at 100% zoom: one Right press 62–64 px in two trials, Shift+Right about 320 px, reading offsets from screenshots, about ±3 px); Preferences ▸ Invert zoom direction (Figma's Preferences menu has it, checked 2026-11-09; #2145) reverses wheel zoom: Cmd/Ctrl+wheel, and a plain mouse wheel with Scroll wheel zoom on, zoom out where they would zoom in, by the same factor, while a trackpad pinch and panning are unchanged (only the setting's existence was measured, so the pinch is left alone); zoom steps, limits (2%–25,600%) and frame order pinned where the documentation is silent (`view_behaviour_tests`); Zoom to selection (Shift+2) fits the selection into the canvas above the floating bottom toolbar with a 40 pt margin on all four sides, centred in that area, at a continuous zoom (measured in Figma's web app, 2026-11-09; `zoom_to_selection_leaves_forty_points_and_clears_the_toolbar`, `zoom_to_selection_on_a_wide_layer_is_limited_by_the_width`, `zoom_to_selection_without_a_toolbar_inset_uses_the_whole_height`); Zoom to fit (Shift+1) keeps its 64 pt margin, margin not measured yet (`zoom_to_fit_is_unchanged`). A file opens again on the page it showed and at its view, each of its pages at the view it was left at, when its tab closed or the app quit: kept in the preferences by path for the last 100 files, never in the file, so looking around doesn't change it | | Auto-pan when a drag holds the pointer near the canvas edge | done | measured in Figma (web, 100% zoom, held drags; #2015): while a drag holds the pointer within about 15 px of the canvas viewport's edge, or past it, the view pans toward that edge by itself at `40 x (15 - d)` screen px per second (d: px inside the edge, negative outside; 0 at 15 px or more, 120 at 12 px, about 280 at 8 px, 520 at 2 px, 600 at the edge and beyond), steadily while the pointer stays still, no acceleration; two edges (a corner) pan both axes, each by its own distance. Covers moving layers (once past the drag threshold), the selection box (once it has grown past it), drawing a shape and dragging a prototype connection out of a layer, so a link can reach a frame off screen; the layer, box, shape or connection follows the document point under the pointer. Not for resizing, rotating, the hand or Space panning, text selection or vector edits (not measured). Speed taken as screen px per second at every zoom (other zooms not measured). The rule is `ViewState::autopan_velocity`, applied each frame by the canvas (`view_autopan_tests`, `canvas_autopan_tests`, `proto_canvas`) | | Rulers and guides (drag out, move, remove; rotated frames; frame guides) | done | guides belong to the page or a top-level frame (a frame moved into another keeps its guides but they stop applying); a click selects one for Delete, the arrows or the context menu's Remove guide; Alt-drag drops a copy; Alt while dragging measures to the layers in the frame it crosses; ruler numbering checked by eye only | | Frame labels (rotated, right-to-left), size badge | done | | @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-24 | minor | M5: a file opens again where it was left, as Figma opens a file where you were. Closing its tab or quitting keeps the page it showed and each page's view (centre and zoom) in the preferences by path, for the last 100 files left; opening it shows that page at its view, and the canvas keeps the view instead of fitting the page when it gets its size. Each other page shows its view when it's opened. A page the file no longer has, a divider or a view the canvas can't show is left out, and the file opens fitted as before. Nothing goes into the file: looking around doesn't make it unsaved. Tests: `file_views::tests` (4). Numbers unchanged | | 2026-11-20 | patch | The desktop app started in a new, empty file every time, whatever was open when it quit. It now opens those files again, in their tabs' order with the same one in front, as Figma's desktop app reopens its tabs; quitting keeps their paths with the preferences (files without one, such as new or imported files, and branch tabs are left out). A file named on the command line still opens and stays in front, a recovered copy keeps its one tab, a file gone since is skipped and one that won't open says why. With nothing to reopen the app starts on the Home screen; with a control port open (`--control`) it still starts in a new file, so control callers have a document. Preferences ▸ Start on the Home screen starts there instead of reopening the files. Tests: `reopen_tests` (4), `start_tests` (2). Numbers unchanged | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | From 338318aaac270afba9f3ac3b4d0c39f110d924e9 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:35:28 -0500 Subject: [PATCH 21/36] M3: a panel menu taller than the window scrolls A menu opened from a panel ran past the window's bottom when it had more rows than fit, and the rows below couldn't be reached. With many colour variables, the Selection colors Styles menu showed only the first ones. egui moves a popup to keep it in the window but doesn't shorten one taller than the window. menu_popup, context_popup and the row context menus now return a Menu whose rows scroll with the wheel or the scroll bar once they were taller than the window last frame, the rule the main menu follows since #2217. A menu that fits is laid out as before. A scroll area around every menu's rows was tried first and rejected: egui lays a popup out in the height it measured last frame, so a menu that grows (the share popover opening its Advanced part) stayed at its old height and hid the new rows. Ten share and vote tests caught it. --- crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/menu_scroll_tests.rs | 60 ++++++++++++++++++++++ crates/ui-egui/src/panels/right/menu.rs | 67 ++++++++++++++++++++++--- docs/ui-parity.md | 5 +- 4 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 crates/ui-egui/src/menu_scroll_tests.rs diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 32d859f6c..129bd3dc4 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -196,6 +196,8 @@ mod menu_input_tests; #[cfg(test)] mod menu_overflow_tests; #[cfg(test)] +mod menu_scroll_tests; +#[cfg(test)] mod mirror_tests; #[cfg(test)] mod missing_fonts_tests; diff --git a/crates/ui-egui/src/menu_scroll_tests.rs b/crates/ui-egui/src/menu_scroll_tests.rs new file mode 100644 index 000000000..8b12b2495 --- /dev/null +++ b/crates/ui-egui/src/menu_scroll_tests.rs @@ -0,0 +1,60 @@ +//! A panel menu taller than the window scrolls, so its last rows can be reached and picked: the +//! page's variable mode menu of a collection with more modes than fit. + +use egui::{Event, Modifiers, MouseWheelUnit, PointerButton, Pos2, TouchPhase, vec2}; +use figcraft_engine::Session; +use serde_json::json; + +use crate::layers_drag_tests::Ui; +use crate::live_tests::{flat, text_center, texts}; + +/// A click at `p`, and the frames that follow; what the last frame drew. +fn click(u: &mut Ui, p: Pos2) -> Vec { + for _ in 0..5 { + u.frame(vec![Event::PointerMoved(p)]); + } + let mut shapes = Vec::new(); + for pressed in [Some(true), Some(false)].into_iter().chain(std::iter::repeat_n(None, 20)) { + let events = pressed.map(|pressed| Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + shapes = flat(&u.frame_output(events.into_iter().collect()).shapes); + } + shapes +} + +/// Where `label` is drawn, if it is. +fn at(shapes: &[egui::Shape], label: &str) -> Option { + texts(shapes).into_iter().find(|(t, ..)| t == label).map(|(_, p, size)| p + size / 2.0) +} + +#[test] +fn a_menu_taller_than_the_window_scrolls_to_its_last_row() { + let modes: Vec = (0..60).map(|k| format!("Mode {k}")).collect(); + let mut s = Session::new(); + s.execute("variable.createCollection", &json!({"name": "Theme", "modes": modes})).unwrap(); + s.execute("select.set", &json!({"ids": []})).unwrap(); + let mut u = Ui::new(s); + let shapes = flat(&u.frame_output(vec![]).shapes); + let menu = click(&mut u, text_center(&shapes, "Auto (Mode 0)")); + let first = at(&menu, " Mode 0").expect("the menu is open"); + assert!(at(&menu, " Mode 59").is_none_or(|p| p.y > 900.0), "the last row starts below the window"); + let wheel = Event::MouseWheel { + unit: MouseWheelUnit::Point, + source: egui::MouseWheelSource::Unknown, + delta: vec2(0.0, -5000.0), + phase: TouchPhase::Move, + modifiers: Modifiers::NONE, + }; + u.frame(vec![Event::PointerMoved(first), wheel]); + for _ in 0..30 { + u.frame(vec![]); + } + let shapes = flat(&u.frame_output(vec![]).shapes); + let last = at(&shapes, " Mode 59").expect("scrolled to the last row"); + assert!(last.y < 900.0, "inside the window: {last:?}"); + click(&mut u, last); + let page = u.app.session.page().unwrap(); + let doc = u.app.session.doc().unwrap(); + let coll = &doc.variables.collections[0]; + let picked = coll.modes.iter().find(|m| m.name == "Mode 59").unwrap().id.clone(); + assert_eq!(doc.node(page).unwrap().var_modes.get(&coll.id), Some(&picked), "the last mode is picked"); +} diff --git a/crates/ui-egui/src/panels/right/menu.rs b/crates/ui-egui/src/panels/right/menu.rs index 8f6e7f7fd..15c6d1af2 100644 --- a/crates/ui-egui/src/panels/right/menu.rs +++ b/crates/ui-egui/src/panels/right/menu.rs @@ -44,22 +44,77 @@ pub(crate) fn preview_blend(app: &mut FigApp, ctx: &egui::Context, ids: &[NodeId /// (else its 600 px default area width) and keeps the size measured; rows ([`menu_row`]) take the /// larger of that width and their content, so the menu fits its content. Chain `.width(w)` for a /// menu at least `w` wide. -pub fn menu_popup(anchor: &egui::Response) -> egui::Popup<'static> { - egui::Popup::menu(anchor).width(anchor.rect.width().max(MENU_MIN_W)).style(menu_style) +pub fn menu_popup(anchor: &egui::Response) -> Menu { + Menu(egui::Popup::menu(anchor).width(anchor.rect.width().max(MENU_MIN_W)).style(menu_style)) } /// A context menu (secondary click on `resp`) sized like [`menu_popup`]. -pub fn context_popup(resp: &egui::Response) -> egui::Popup<'static> { - egui::Popup::context_menu(resp).width(MENU_MIN_W).style(menu_style) +pub fn context_popup(resp: &egui::Response) -> Menu { + Menu(egui::Popup::context_menu(resp).width(MENU_MIN_W).style(menu_style)) } /// A context menu for a property row: a secondary click anywhere over `rect` opens it, even over /// the row's fields (which would otherwise take the click), like the incumbent's row menus. -pub(super) fn row_context_menu(ui: &Ui, rect: Rect, id: Id) -> egui::Popup<'static> { +pub(super) fn row_context_menu(ui: &Ui, rect: Rect, id: Id) -> Menu { let resp = ui.interact(rect, id, Sense::hover()); let open = ui.rect_contains_pointer(rect) && ui.input(|i| i.pointer.secondary_clicked()); let at_pointer = egui::Popup::menu(&resp).width(MENU_MIN_W).style(menu_style).at_pointer_fixed(); - at_pointer.open_memory(open.then_some(egui::SetOpenCommand::Bool(true))) + Menu(at_pointer.open_memory(open.then_some(egui::SetOpenCommand::Bool(true)))) +} + +/// The gap a menu taller than the window keeps from the window's top and bottom edges. +const MENU_WINDOW_GAP: f32 = 8.0; + +/// A popup menu ([`menu_popup`], [`context_popup`]) whose rows scroll when it would be taller +/// than the window. egui keeps a popup inside the window by moving it, but one taller than the +/// window runs off its edge, and rows past it can't be reached. +#[must_use] +pub struct Menu(egui::Popup<'static>); + +impl Menu { + /// At least `width` wide. + pub fn width(self, width: f32) -> Self { + Self(self.0.width(width)) + } + + /// Open and closed under `id` instead of the anchor's. + pub fn id(self, id: Id) -> Self { + Self(self.0.id(id)) + } + + pub fn close_behavior(self, behavior: egui::PopupCloseBehavior) -> Self { + Self(self.0.close_behavior(behavior)) + } + + /// Show the menu while it is open. Its rows `content` scroll with the wheel or the scroll bar + /// once they were taller than the window last frame, as the main menu's do (#2217); a menu + /// that fits is laid out as it is, so it still grows with its rows (a scroll area in a popup + /// would keep the popup's last height). + pub fn show(self, content: impl FnOnce(&mut Ui) -> R) -> Option> { + self.0.show(|ui| { + let window = ui.ctx().content_rect().height(); + let max_height = (window - ui.style().spacing.menu_margin.sum().y - 2.0 * MENU_WINDOW_GAP).max(0.0); + let rows_height = ui.scope_id().with("menu_rows_height"); + let last = ui.data(|d| d.get_temp::(rows_height)).unwrap_or(0.0); + let (inner, height) = if last > max_height { + let out = egui::ScrollArea::vertical() + .id_salt("menu_rows") + .max_height(max_height) + .scroll_source(egui::scroll_area::ScrollSource::MOUSE_WHEEL | egui::scroll_area::ScrollSource::SCROLL_BAR) + .show(ui, content); + (out.inner, out.content_size.y) + } else { + let inner = content(ui); + let height = ui.min_rect().height(); + if height > max_height { + ui.ctx().request_repaint(); + } + (inner, height) + }; + ui.data_mut(|d| d.insert_temp(rows_height, height)); + inner + }) + } } pub fn menu_item(ui: &mut Ui, label: &str, shortcut: &str) -> bool { diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..448ce05a8 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-23 · **Change:** minor (a dropdown, button menu or context menu in the panels that is taller than the window scrolls, so its last rows can be picked; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -23,7 +23,7 @@ interaction feel only partly compared: the interactions measured so far, case by | Actions palette (Cmd+K, Cmd+/) | done | tabs: All (every command, grouped by menu, or Other; a command that needs parameters only through its menu item, and none twice under one label, #1574), Assets (components and styles) and Plugins & widgets; results ranked prefix first, then shortest, at most 60 rows; Up/Down move a highlight and Enter runs it; Recents list what was run from the palette (matching translated labels); one open/toggle path from every entry point (`palette_tests`). Ranking and the Assets results not compared with Figma's | | Context menus | done | canvas and layers; submenus as in the main menu below, and a right-click in a new spot starts a fresh menu (Select layer closed); Shift+F10 or the keyboard's Menu key opens them from the keyboard (at the focused layer row or below the canvas selection) and the menu takes the keyboard (`layers_keyboard_tests`) | | Home screen: Recents, Online and Templates | done (ours) | The sidebar switches between the three (`ui.set {homeSection}`). Online: your online files (see the collaboration checklist). Recents: new file, open, join with a code, open files, recent files (cards with the picture each file carries on its page colour, the file's icon, name and "Edited ... ago" or "File not found", full path on hover; or a Name, Last modified and Created table with sortable headers; sorted by name, creation or last change either way; grid or list and the sort kept in the preferences, `ui.set {homeRecentsView, homeRecentsSort, homeRecentsOrder}`; a click selects, a double-click or Enter opens, arrow keys move the selection; Open, Show in folder and Remove from recents on right-click), a Getting started card (six tips with their shortcuts from the keymap; its close button is remembered in the preferences and Help ▸ Getting started brings it back) and, while there are no recent files, four templates to start from. Templates: the eight starter templates as cards (thumbnail rendered from the document, cached per theme; name, description, kind and size), a search field and a kind filter, an empty state; Tab reaches every card and Enter opens it; cards and tabs are named for screen readers. A first run opens here. No Community files or drafts folder | -| Main menu from the logo | done | generated from `catalog.rs`; popups sized to content. Submenus open on the first frame their row is hovered (a click or the keyboard opens one at once; Figma's main menu measured 2026-11-07 with synthetic pointer events: median 11 ms to open, 13 ms to switch rows) and close at once when another row is hovered; while the pointer heads for an open submenu inside the triangle to its near edge, the rows it crosses don't take over, and resting 0.3 s on one hands over; closing the menu, however it closes, clears which submenus were open, so it reopens with none (`menu_aim_tests`, 10 tests; the open delay is measured; the safe triangle and its 0.3 s rest are still tuned by feel, and Figma's main menu showed no triangle at all in that measurement, so the aim is kept pending the maintainer's decision). A menu or submenu that would run past the window's bottom moves up to fit (never above the top), and one taller than the window scrolls with the wheel, the keyboard's focus kept in view; the context menu's submenus share this (#2217, `menu_overflow_tests`). Menu and palette items that need a value ask for it first: Create link, Offset path and Move to page in a dialog of the shared controls, the language, user name, server and nudge items in Preferences, Open recent on the home screen's Recents; File ▸ Rename edits the file name in place | +| Main menu from the logo | done | generated from `catalog.rs`; popups sized to content. Submenus open on the first frame their row is hovered (a click or the keyboard opens one at once; Figma's main menu measured 2026-11-07 with synthetic pointer events: median 11 ms to open, 13 ms to switch rows) and close at once when another row is hovered; while the pointer heads for an open submenu inside the triangle to its near edge, the rows it crosses don't take over, and resting 0.3 s on one hands over; closing the menu, however it closes, clears which submenus were open, so it reopens with none (`menu_aim_tests`, 10 tests; the open delay is measured; the safe triangle and its 0.3 s rest are still tuned by feel, and Figma's main menu showed no triangle at all in that measurement, so the aim is kept pending the maintainer's decision). A menu or submenu that would run past the window's bottom moves up to fit (never above the top), and one taller than the window scrolls with the wheel, the keyboard's focus kept in view; the context menu's submenus share this (#2217, `menu_overflow_tests`). The panels' dropdowns, button menus and context menus do the same: one taller than the window scrolls with the wheel or its scroll bar, as the Selection colors Styles menu with many colour variables did not. Menu and palette items that need a value ask for it first: Create link, Offset path and Move to page in a dialog of the shared controls, the language, user name, server and nudge items in Preferences, Open recent on the home screen's Recents; File ▸ Rename edits the file name in place | | Keyboard shortcuts panel | done | closes when the home screen shows (#548); docked, tabbed by group like the documentation, searchable, per-platform keycaps; held keys, gestures and presentation keys listed beside the bindings; a label too long for its column ends with "…" and shows in full on hover | | Several windows | partial | File ▸ New window, Open in new window on a tab, a tab dragged off the strip; screen-reader tree in the main window only; positions not restored | | Multiplayer avatars, Share button | missing | waits for multiplayer | @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-23 | patch | M3: a menu opened from a panel (a dropdown, a button's menu such as the Selection colors Styles menu, a row's context menu) ran past the window's bottom when it had more rows than fit, and the rows below couldn't be reached: with many colour variables the Styles menu showed only the first ones. egui moves a popup to keep it in the window but doesn't shorten one taller than the window. `menu_popup`, `context_popup` and the row context menus now return a `Menu` whose rows scroll with the wheel or the scroll bar once they were taller than the window last frame, as the main menu's do (#2217); a menu that fits is laid out as before and still grows with its rows. Test: `menu_scroll_tests::a_menu_taller_than_the_window_scrolls_to_its_last_row` (the page's variable mode menu of a collection with 60 modes). Numbers unchanged | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 7ce0e374a172b483111257781ce0051f0a5d38f1 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:22:35 -0500 Subject: [PATCH 22/36] M3: the pixel grid shows on dark as well as on white The grid was black at 7%, a stroke of one point: it showed on white and hardly at all on the dark canvas or a dark fill, and on a 2x screen its lines were two pixels wide. Figma's grid reads 242 on white and 78 on a grey of 50 (measured 2026-11-24), which a grey of 190 at 20% gives, so it darkens light colours and lightens dark ones. The lines are now that grey, one screen pixel wide and centred on the screen's pixels. --- crates/ui-egui/src/canvas.rs | 2 +- crates/ui-egui/src/canvas/overlays.rs | 15 ++++--- crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/pixel_grid_tests.rs | 54 ++++++++++++++++++++++++++ docs/ui-parity.md | 3 +- 5 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 crates/ui-egui/src/pixel_grid_tests.rs diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 3d3f05082..068ea3ef6 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -19,7 +19,7 @@ mod background; mod builder; mod input; mod outline; -mod overlays; +pub(crate) mod overlays; mod render; mod rulers; diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index b285d8792..fdb4267b2 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -171,22 +171,27 @@ pub(super) fn overlays(app: &FigApp, painter: &egui::Painter, t: &Tokens) -> Vec labels } +/// The pixel grid's lines: one screen pixel wide, a light grey at a fifth of its strength, so +/// they darken white and lighten a dark canvas or fill alike. Measured in Figma (2026-11-24): +/// 242 on white and 78 on a grey of 50, which this grey gives. +pub(crate) const PIXEL_GRID: Color32 = Color32::from_rgba_unmultiplied_const(190, 190, 190, 51); + /// Pixel grid at high zoom. fn pixel_grid(app: &FigApp, painter: &egui::Painter) { let r = app.canvas.rect; let p0 = app.to_page(r.min); let p1 = app.to_page(r.max); - let col = Color32::from_black_alpha(18); + let line = stroke(PIXEL_GRID, 1.0 / painter.pixels_per_point()); let mut x = p0.x.floor(); while x <= p1.x { - let s = app.to_screen(x, 0.0).x; - painter.line_segment([pos2(s, r.min.y), pos2(s, r.max.y)], stroke(col, 1.0)); + let s = painter.round_to_pixel_center(app.to_screen(x, 0.0).x); + painter.line_segment([pos2(s, r.min.y), pos2(s, r.max.y)], line); x += 1.0; } let mut y = p0.y.floor(); while y <= p1.y { - let s = app.to_screen(0.0, y).y; - painter.line_segment([pos2(r.min.x, s), pos2(r.max.x, s)], stroke(col, 1.0)); + let s = painter.round_to_pixel_center(app.to_screen(0.0, y).y); + painter.line_segment([pos2(r.min.x, s), pos2(r.max.x, s)], line); y += 1.0; } } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 32d859f6c..75264829b 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -225,6 +225,8 @@ mod pen_mode_tests; #[cfg(test)] mod perf_tests; #[cfg(test)] +mod pixel_grid_tests; +#[cfg(test)] mod plugin_panel_tests; #[cfg(test)] mod plugin_save_ui_tests; diff --git a/crates/ui-egui/src/pixel_grid_tests.rs b/crates/ui-egui/src/pixel_grid_tests.rs new file mode 100644 index 000000000..fbf1c3003 --- /dev/null +++ b/crates/ui-egui/src/pixel_grid_tests.rs @@ -0,0 +1,54 @@ +//! The pixel grid, drawn headless: from 400% its lines are one screen pixel wide and a grey that +//! shows on a white frame and on the dark canvas alike, as in Figma. + +use egui::{Color32, RawInput, Shape, ViewportId, ViewportInfo}; +use figcraft_engine::Session; +use serde_json::json; + +use crate::canvas::overlays::PIXEL_GRID; +use crate::layers_drag_tests::Ui; +use crate::live_tests::flat; + +/// The width of each grid line drawn in a frame on a screen of `native` pixels per point (the +/// last of a few, for a new scale to take effect). +fn grid_lines(u: &mut Ui, native: f32) -> Vec { + let mut out = None; + for _ in 0..4 { + let mut raw = RawInput::default(); + raw.viewports.insert(ViewportId::ROOT, ViewportInfo { native_pixels_per_point: Some(native), ..Default::default() }); + out = Some(u.frame_raw(raw)); + } + let shapes = flat(&out.map(|o| o.shapes).unwrap_or_default()); + shapes + .iter() + .filter_map(|s| match s { + Shape::LineSegment { stroke, .. } if stroke.color == PIXEL_GRID => Some(stroke.width), + _ => None, + }) + .collect() +} + +/// `c` drawn over a grey of `bg`, as the canvas blends it. +fn over(c: Color32, bg: u8) -> f32 { + let [r, _, _, a] = c.to_srgba_unmultiplied(); + let a = f32::from(a) / 255.0; + f32::from(bg) * (1.0 - a) + f32::from(r) * a +} + +#[test] +fn the_pixel_grid_shows_on_white_and_on_dark_one_screen_pixel_wide() { + let mut s = Session::new(); + s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 100, "height": 100})).unwrap(); + let mut u = Ui::new(s); + u.app.session.ds_mut().unwrap().view.zoom = 8.0; + let widths = grid_lines(&mut u, 1.0); + assert!(!widths.is_empty(), "the grid draws at 800%"); + assert!(widths.iter().all(|w| *w == 1.0), "one screen pixel: {widths:?}"); + // Measured in Figma (2026-11-24): a grid line is 242 on white and 78 on a grey of 50. + assert_eq!((over(PIXEL_GRID, 255).round(), over(PIXEL_GRID, 50).round()), (242.0, 78.0)); + // On a 2x screen the lines stay one of its pixels wide. + let widths = grid_lines(&mut u, 2.0); + assert!(!widths.is_empty() && widths.iter().all(|w| *w == 0.5), "{widths:?}"); + u.app.session.ds_mut().unwrap().view.zoom = 3.0; + assert!(grid_lines(&mut u, 2.0).is_empty(), "no grid below 400%"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..ca046ec2e 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (the pixel grid shows on a dark canvas and dark fills as well as on white, its lines one screen pixel wide in a light grey at a fifth of its strength, as measured in Figma; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-24 | patch | M3: the pixel grid was drawn in black at 7% and two pixels wide on a Retina screen, so it showed on white and hardly at all on the dark canvas or a dark fill. Its lines are now a light grey (190) at 20%, one screen pixel wide and on the screen's pixels: 242 on white and 78 on a grey of 50, as measured on Figma's grid (2026-11-24), so they darken a light colour and lighten a dark one. Test: `pixel_grid_tests` (800%, a 1x and a 2x screen, none below 400%). | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 5a875417e79540c926ac53a936dc73d4b71641fd Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:22:35 -0500 Subject: [PATCH 23/36] M8: frames, sections and components land on whole pixels Figma's help says they "always snap to the pixel grid, even if Snap to pixel grid is disabled". In FigCraft they followed the setting like any layer, and since #2031 a snap to a layer off the grid wins over the grid, so a frame dragged next to a neighbour at 100.4 landed at 100.4 and the whole numbers inside it sat between pixels. A move, resize or draw of frames, sections, components, component sets and instances now rounds to whole pixels before and after object snapping, whatever Snap to pixel grid says. A moved one also lands on whole pixels of its parent (`snap::settle_on_pixels`), so a frame already off the grid comes back onto it. Other layers keep #2031's order: the pixel grid first, then the snap to a layer wins. The move rounds the drag itself rather than each layer afterwards, so the preview keeps its shifted-layers fast path for frames already on the grid. --- crates/engine/src/canvas/snap.rs | 21 +++++++++- crates/engine/src/canvas/tools/drag.rs | 25 ++++++++++- crates/engine/src/canvas/tools/draw.rs | 11 ++++- .../engine/src/transform_behaviour_tests.rs | 42 +++++++++++++++++++ docs/mcp.md | 3 +- docs/ui-parity.md | 5 ++- 6 files changed, 100 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/canvas/snap.rs b/crates/engine/src/canvas/snap.rs index ff1a6b64d..329f7503c 100644 --- a/crates/engine/src/canvas/snap.rs +++ b/crates/engine/src/canvas/snap.rs @@ -4,13 +4,32 @@ //! guide lines (with spacing labels) for the canvas to draw in red. Vector points also snap to //! other points (see `vectoredit::snap`); landing on one shows a marker (a zero-length guide). -use figcraft_doc::{BoardItem, Document, NodeId}; +use figcraft_doc::{BoardItem, Document, Node, NodeId, NodeKind}; use figcraft_geom::{Affine, Point, Rect, Vec2, transform_rect_bbox}; use serde::Serialize; use crate::guides; use crate::tools::UNMEASURED_SNAP_PX; +/// Whether `n` lands on whole pixels when dragged whatever Snap to pixel grid says: frames, +/// sections, components, component sets and instances. Figma's help: they "always snap to the +/// pixel grid, even if Snap to pixel grid is disabled". Other layers follow the setting. +pub fn always_on_pixels(n: &Node) -> bool { + n.kind.is_frame_like() || matches!(n.kind, NodeKind::Section { .. }) +} + +/// Put `id`'s position in its parent on whole pixels when its axes are its parent's: returns +/// whether it moved. A layer turned off its parent's axes keeps its position. +pub fn settle_on_pixels(doc: &mut Document, id: NodeId) -> crate::Result { + let n = doc.get_mut(id)?; + let [a, b, c, d, e, f] = n.transform.as_coeffs(); + if !guides::axis_aligned(n.transform) || (e.round() == e && f.round() == f) { + return Ok(false); + } + n.transform = Affine::new([a, b, c, d, e.round(), f.round()]); + Ok(true) +} + /// A guide line to draw: from (x0, y0) to (x1, y1) in page coordinates, with an optional label /// (a distance) at its middle; `dashed` marks a measurement's extension line. #[derive(Clone, Debug, PartialEq, Serialize)] diff --git a/crates/engine/src/canvas/tools/drag.rs b/crates/engine/src/canvas/tools/drag.rs index 84ca02ba4..75e8e8c44 100644 --- a/crates/engine/src/canvas/tools/drag.rs +++ b/crates/engine/src/canvas/tools/drag.rs @@ -249,7 +249,11 @@ impl Session { let raw = d; let snap_on = self.ds().map(|ds| ds.view.snap_objects).unwrap_or(true) && !ev.cmd && !ev.ctrl; let mut guides = Vec::new(); - if self.ds().map(|ds| ds.view.snap_pixel).unwrap_or(true) { + let boards = { + let doc = self.doc()?; + ids.iter().all(|i| doc.node(*i).is_some_and(crate::snap::always_on_pixels)) + }; + if boards || self.ds().map(|ds| ds.view.snap_pixel).unwrap_or(true) { // Keep the box's origin on whole pixels (a rotated parent frame's, inside one); // snapping to layers comes after, so it wins on the axes it snaps. d = targets.round_move(d); @@ -259,6 +263,11 @@ impl Session { d += c; guides = g2; } + if boards { + // Frames, sections and components stay on whole pixels even where a layer + // they snap to doesn't. + d = targets.round_move(d); + } let ids = ids.clone(); let dup = *duplicate; let page = self.page()?; @@ -343,6 +352,9 @@ impl Session { doc.reparent(*m, page, None)?; } move_world(doc, *m, d.x, d.y)?; + if doc.node(*m).is_some_and(crate::snap::always_on_pixels) { + shifted &= !crate::snap::settle_on_pixels(doc, *m)?; + } } drop_target = (flow && target != page).then_some(target); Ok(()) @@ -521,7 +533,13 @@ impl Session { // The pixel grid: an upright box's dragged sides land on whole pixels (the Scale tool // scales by the factor as dragged). Snapping to layers comes after, so it wins on the axes // it snaps. - if !scale_tool && self.ds().map(|d| d.view.snap_pixel).unwrap_or(true) && crate::guides::axis_aligned(frame) { + // Frames, sections and components land on whole pixels whatever the setting, also where a + // layer they snap to doesn't. + let boards = { + let doc = self.doc()?; + !scale_tool && crate::guides::axis_aligned(frame) && ids.iter().all(|i| doc.node(*i).is_some_and(crate::snap::always_on_pixels)) + }; + if boards || !scale_tool && self.ds().map(|d| d.view.snap_pixel).unwrap_or(true) && crate::guides::axis_aligned(frame) { p = Point::new(p.x.round(), p.y.round()); } if let Some(t) = &targets { @@ -530,6 +548,9 @@ impl Session { p.y += dy; guides = g; } + if boards { + p = Point::new(p.x.round(), p.y.round()); + } let q = frame.inverse() * p; let is_line = r.single && ids.first().and_then(|i| self.doc().ok()?.node(*i).map(|n| matches!(n.kind, NodeKind::Line))).unwrap_or(false); if scale_tool { diff --git a/crates/engine/src/canvas/tools/draw.rs b/crates/engine/src/canvas/tools/draw.rs index b29768afe..867567618 100644 --- a/crates/engine/src/canvas/tools/draw.rs +++ b/crates/engine/src/canvas/tools/draw.rs @@ -30,7 +30,10 @@ impl Session { let tool = self.tool.tool; let mut p = ev.p(); let mut guides = Vec::new(); - let pixel = self.ds().map(|d| d.view.snap_pixel).unwrap_or(true); + // Frames and sections land on whole pixels whatever the setting, also where a layer they + // snap to doesn't (see `snap::always_on_pixels`). + let board = matches!(tool, ToolId::Frame | ToolId::Section); + let pixel = board || self.ds().map(|d| d.view.snap_pixel).unwrap_or(true); // The pixel grid first: snapping to layers comes after, so it wins on the axes it snaps. if pixel { p = Point::new(p.x.round(), p.y.round()); @@ -41,6 +44,9 @@ impl Session { p.y += dy; guides = g; } + if board { + p = Point::new(p.x.round(), p.y.round()); + } let mut created = id; let page = self.page()?; // Edit ▸ Set default properties: what new shapes take (not frames, sections, slices, lines @@ -100,6 +106,9 @@ impl Session { n.transform = pw.inverse() * Affine::translate((r.x0, r.y0)); } doc.insert(n, parent, None)?; + if board { + crate::snap::settle_on_pixels(doc, nid)?; + } if let Some(d) = &defaults { // Best effort: a default the shape can't take leaves it as drawn. let _ = crate::cmd::edit::apply_copied_props("edit.setDefaultProperties", doc, nid, d); diff --git a/crates/engine/src/transform_behaviour_tests.rs b/crates/engine/src/transform_behaviour_tests.rs index 3c37bf6c0..e62024380 100644 --- a/crates/engine/src/transform_behaviour_tests.rs +++ b/crates/engine/src/transform_behaviour_tests.rs @@ -795,6 +795,48 @@ fn snapping_to_layers_wins_over_the_pixel_grid() { assert_eq!(size(&s, b), (100.0, 151.0)); } +#[test] +fn frames_land_on_whole_pixels_whatever_they_snap_to() { + // Figma's help: frames, sections and components "always snap to the pixel grid, even if Snap + // to pixel grid is disabled". Other layers follow the setting. + let frame = |s: &mut Session, x: f64, y: f64| id(&ex(s, "frame.create", json!({"x": x, "y": y, "width": 100, "height": 100}))); + let whole = |r: Rect| [r.x0, r.y0, r.x1, r.y1].iter().all(|v| v.fract() == 0.0); + let mut s = Session::new(); + // A neighbour off the pixel grid, as a scaled or imported layer leaves one: its right edge at + // 100.4. + rect(&mut s, 0.4, 0.0, 100.0, 100.0, None); + let f = frame(&mut s, 300.0, 300.0); + let r = rect(&mut s, 300.0, 600.0, 100.0, 100.0, None); + // Moved next to it, a rectangle snaps onto 100.4 and the frame to the whole pixel there. + ex(&mut s, "select.set", json!({"ids": [r]})); + drag(&mut s, Point::new(350.0, 650.0), Point::new(151.5, 650.0), Mods::default()); + assert!(near(bounds(&s, r).x0, 100.4), "{:?}", bounds(&s, r)); + ex(&mut s, "select.set", json!({"ids": [f]})); + drag(&mut s, Point::new(350.0, 350.0), Point::new(151.5, 350.0), Mods::default()); + assert_eq!(bounds(&s, f).origin(), Point::new(100.0, 300.0), "moved by the snap, onto the whole pixel"); + // With Snap to pixel grid off, frames still move, resize and draw on whole pixels. + ex(&mut s, "view.snapPixel", json!({"on": false})); + ex(&mut s, "view.snapObjects", json!({"on": false})); + drag(&mut s, Point::new(150.0, 350.0), Point::new(160.3, 360.6), Mods::default()); + assert_eq!(bounds(&s, f).origin(), Point::new(110.0, 311.0), "moved"); + drag(&mut s, Point::new(210.0, 411.0), Point::new(250.4, 450.6), Mods::default()); + assert_eq!(size(&s, f), (140.0, 140.0), "resized"); + ex(&mut s, "tool.set", json!({"tool": "frame"})); + drag(&mut s, Point::new(500.3, 500.6), Point::new(560.6, 540.2), Mods::default()); + let drawn = s.selection()[0]; + assert!(whole(bounds(&s, drawn)), "drawn: {:?}", bounds(&s, drawn)); + // A frame already off the pixel grid lands on it once moved. + ex(&mut s, "tool.set", json!({"tool": "move"})); + let off = frame(&mut s, 800.4, 800.7); + ex(&mut s, "select.set", json!({"ids": [off]})); + drag(&mut s, Point::new(850.0, 850.0), Point::new(860.0, 850.0), Mods::default()); + assert!(whole(bounds(&s, off)), "{:?}", bounds(&s, off)); + // A rectangle follows the pointer. + ex(&mut s, "select.set", json!({"ids": [r]})); + drag(&mut s, Point::new(150.0, 650.0), Point::new(160.3, 650.0), Mods::default()); + assert!(near(bounds(&s, r).x0, 110.7), "{:?}", bounds(&s, r)); +} + #[test] fn corner_cursors_stay_diagonal_whatever_the_proportions() { let mut s = session(); diff --git a/docs/mcp.md b/docs/mcp.md index c1f3992a9..dce9cf986 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2173,7 +2173,8 @@ turned off 0°. `cmd` while resizing a frame ignores its children's constraints (they stay where they are) and, as in every drag, turns snapping off. Moves snap to edges, centres and equal spacing (the gaps show in `tool.overlay.guides` with labels); with the pixel grid on, moves and resizes land on - whole pixels. + whole pixels. Frames, sections, components and instances always land on whole pixels of their + parent, with the pixel grid off too and after a snap to a layer off the grid. Tool failures come back as results with `isError: true` and a message; protocol problems (unknown tool, malformed JSON, wrong parameter types) are JSON-RPC errors. Nothing crashes the server. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..d0277b50a 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (frames, sections, components and instances move, resize and draw on whole pixels whatever Snap to pixel grid says and whatever they snap to, as Figma's help says; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -75,7 +75,7 @@ interaction feel only partly compared: the interactions measured so far, case by | Smart guides: edges, centres, equal spacing (between two layers or continuing a row's gap, labelled), spacing labels, parent, layout grid, ruler guides | done | red, `snap.rs`; a guide dragged out of a ruler or moved snaps to layer edges and centres too (Snap to Objects; Cmd/Ctrl suspends), on its own axis only; page guides see the page's top-level layers, frame guides the frame's box, layout grids and every layer in it, along a rotated frame's own axes; the object snap threshold is 4.5 screen pixels, measured against Figma (snapped at a gap of 4.4 screen px, not at 4.6, at 100% and 200% zoom, 2026-11-08; the equal-spacing snap shares it), but the ruler-guide and rotation-origin thresholds (5 px), the red guide's look and snapping with Snap to pixel grid off are not yet compared with Figma's (`guide_snap_tests`, `transform_behaviour_tests`) | | Ctrl to suspend snapping while dragging (macOS) | done | Control on macOS (Cmd keeps working), Ctrl elsewhere; moving, resizing and drawing | | Measure (Alt hover, Cmd+Alt nested, Shift+Alt padding/gaps) | done | labels never overlap; the arrows still nudge while measuring (Shift: the big step) and the distances follow; the selection's handles and size label hide while measuring (`measure_nudge_tests`, #894) | -| Pixel grid snapping, pixel preview, 2x preview | done | moves, resizes and new shapes land on whole pixels; the pixel grid shows from 400% (`view_behaviour_tests`) | +| Pixel grid snapping, pixel preview, 2x preview | done | moves, resizes and new shapes land on whole pixels; frames, sections and components always do, also with snapping off or next to a layer off the grid, as the help says (`frames_land_on_whole_pixels_whatever_they_snap_to`); the pixel grid shows from 400% (`view_behaviour_tests`) | | Numeric fields: arithmetic, scrubbing by dragging the label (or the field itself with Alt held), mixed values | done | Numeric panels use `widgets::number_field`; Corner smoothing has an original code-drawn icon, a 24 pt drag target and an accessible name, with live changes, fractional values preserved across consecutive drags, Shift/Alt rates, 0–100% clamping and one-step undo/redo (`corner_individual_tests`); Typography line height, letter spacing and paragraph spacing share its leading-icon scrub logic (#373), retaining their existing unit parsing, Auto/Mixed values, variable chips and selected-character targeting (`typography_scrub_tests`). Scrubbing the label: half a step a point (0.5 px; 0.5% of opacity, 0.5° of rotation), as measured in Figma on 2026-11-08 (a 12.2 px drag moved X by 6, a 61.2 px drag by 31; rotation by 6° and opacity by 5% for 12.2 px), ten times that with Shift (5 steps a point) and a tenth of that with Alt (0.05 steps a point; neither measured), each stretch at the rate held while it was dragged, one undo step when let go; past the edge of the screen it goes on where the platform reports the mouse's own motion (desktop), otherwise it stops there. Arrow keys: Up/Down step a pixel field by the small nudge and Shift by the big nudge (the preferences), other fields by their own step and ten of it; they work while typing (from what is typed) and with the keyboard on the field. Typing: `+ - * /`, brackets, units (`px`, `°`, `%`, `x`, `ms`), a decimal comma; `+10`, `*2`, `/4` are relative to the value, and `50%`, `+10%`, `-10%` too in a field that isn't a percentage. Enter, Tab or a click elsewhere commits (Tab and Shift+Tab move to the next and previous control), Escape restores; a field left as it was commits nothing (no undo step, and a rounded display isn't written back). Mixed values show "Mixed": a number sets them all, a relative edit or an arrow key goes to each layer from its own value in one undo step, for X, Y, W, H, rotation, opacity, corner radius and stroke weight (elsewhere `+10` on Mixed sets 10 and `*2` does nothing) (`field_tests`). Left: scrubbing a Mixed field (nothing happens), `x2`-style suffix edits, the pointer isn't wrapped to the other side of the screen; the Shift and Alt rates and the speed by height are not compared with Figma's, and the rotation scrub's direction is not confirmed; while scrubbing, the pointer's height sets the speed (more than 100 points above where the scrub began: 2x; that far below: 1/2; twice as far: 1/4), a toast names the speed when it changes, and Shift and Alt multiply as before ("Change the speed that you scrub the field by moving the cursor towards the top of the screen to increase the scrubbing speed, or towards the bottom of the screen to reduce it", Scrub fields; #1837) | | Transform box at small sizes | done | a press inside a layer smaller than its handles moves it, the nearest handle wins, handles answer just outside and are hidden under 16 px on screen; cursors follow each handle and the box's rotation | | Locked layers | done | selectable from the layers panel; no handles, not dragged with the rest of a selection | @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-24 | patch | M8: Figma's help says frames, sections and components always snap to the pixel grid, even with Snap to pixel grid off. In FigCraft they followed the setting like any layer, and a snap to a layer off the grid (a neighbour scaled or imported to 100.4) won over it (#2031), so a frame could land between pixels and the whole numbers inside it sat off the grid. Now a frame, section, component, component set or instance dragged, resized or drawn lands on whole pixels of its parent in either case; a frame off the grid lands on it once moved. Other layers keep the setting, and a snap to a layer still wins for them. Test: `transform_behaviour_tests::frames_land_on_whole_pixels_whatever_they_snap_to`. | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 4fe03065aaa7eba5ae6faf78b13f6effc6094043 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:22:35 -0500 Subject: [PATCH 24/36] M3: Shift+Cmd/Ctrl+' says whether pixel grid snapping is on Turning Snap to pixel grid on or off changes nothing on the canvas until the next drag, so the shortcut gave no sign it had worked. A notice at the bottom now says "Snap to pixel grid on" or "off", from the shortcut, the menu and the Preferences row alike. --- crates/ui-egui/locales/en.toml | 2 ++ crates/ui-egui/locales/ru.toml | 2 ++ crates/ui-egui/src/app/commands.rs | 14 ++++++++++++++ crates/ui-egui/src/shortcut_keys_tests.rs | 17 +++++++++++++++-- docs/ui-parity.md | 3 ++- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/locales/en.toml b/crates/ui-egui/locales/en.toml index e42a1c21c..c5444ca2e 100644 --- a/crates/ui-egui/locales/en.toml +++ b/crates/ui-egui/locales/en.toml @@ -1468,6 +1468,8 @@ name = "English" "Small caps" = "Small caps" "Smart animate" = "Smart animate" "Snap to pixel grid" = "Snap to pixel grid" +"Snap to pixel grid off" = "Snap to pixel grid off" +"Snap to pixel grid on" = "Snap to pixel grid on" "Social and slides" = "Social and slides" "Social media" = "Social media" "Social post sizes" = "Social post sizes" diff --git a/crates/ui-egui/locales/ru.toml b/crates/ui-egui/locales/ru.toml index bc7aa6353..4e4968e6c 100644 --- a/crates/ui-egui/locales/ru.toml +++ b/crates/ui-egui/locales/ru.toml @@ -1347,6 +1347,8 @@ name = "Русский" "Small caps" = "Капитель" "Smart animate" = "Smart animate" "Snap to pixel grid" = "Привязка к пиксельной сетке" +"Snap to pixel grid off" = "Привязка к пиксельной сетке выключена" +"Snap to pixel grid on" = "Привязка к пиксельной сетке включена" "Social and slides" = "Соцсети и слайды" "Social media" = "Соцсети" "Social post sizes" = "Размеры публикаций для соцсетей" diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index e36471b42..c0ddb0130 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -22,9 +22,23 @@ impl FigApp { // `file.open`/`file.close`). Record that presentation before returning, so an in-flight // screenshot admitted on the old file cannot accept pixels from the new one. self.observe_presentation(); + if let Ok(v) = &r { + self.note_snapping(id, v); + } r.map_err(|e| self.failed(id, &e)).ok() } + /// Snap to pixel grid turned on or off says which at the bottom, as in Figma: its shortcut + /// (Shift+Cmd/Ctrl+') changes nothing on the canvas until the next drag. + fn note_snapping(&mut self, id: &str, result: &Value) { + let msg = match (id, result.get("on").and_then(Value::as_bool)) { + ("view.snapPixel", Some(true)) => crate::i18n::tr("Snap to pixel grid on"), + ("view.snapPixel", Some(false)) => crate::i18n::tr("Snap to pixel grid off"), + _ => return, + }; + self.toast(msg); + } + /// A programmatic command that changed the engine clipboard never wrote the system clipboard: /// forget the old system mirror so a later user paste does not trust it as our own copy. /// `before` is the layers generation captured before the command ran. diff --git a/crates/ui-egui/src/shortcut_keys_tests.rs b/crates/ui-egui/src/shortcut_keys_tests.rs index e48a3d0bb..f1fbfd715 100644 --- a/crates/ui-egui/src/shortcut_keys_tests.rs +++ b/crates/ui-egui/src/shortcut_keys_tests.rs @@ -2,8 +2,8 @@ //! headless: arrows pan with nothing selected, the keyboard box selection key and Cmd/Ctrl+arrows //! drawing it out, list indentation while editing text, symbols another keyboard layout types with //! Shift, the presentation keys (Space and N forward, C comments, F full screen), Alt+R for the -//! rotation origin, Enter placing a shape with its tool chosen and Cmd/Ctrl+= and - zooming the -//! canvas, not the interface. +//! rotation origin, Enter placing a shape with its tool chosen, Cmd/Ctrl+= and - zooming the +//! canvas, not the interface, and Shift+Cmd/Ctrl+' saying whether it snaps to the pixel grid. use egui::{Event, Key, Modifiers, ViewportCommand, ViewportId}; use figcraft_doc::NodeId; @@ -299,3 +299,16 @@ fn cmd_alt_arrows_rotate_a_degree_and_fifteen_with_shift() { assert!((rot(&u) - rot_before).abs() < 1e-6, "no turn while editing points"); u.app.run("vector.edit.end", json!({})); } + +#[test] +fn shift_cmd_quote_says_whether_snapping_to_the_pixel_grid_is_on() { + let mut u = Ui::new(Session::new()); + let toast = |u: &Ui| u.app.ui.toast.as_ref().map(|t| t.0.clone()).unwrap_or_default(); + let snap = |u: &Ui| u.app.session.ds().unwrap().view.snap_pixel; + press(&mut u, Key::Quote, cmd() | Modifiers::SHIFT); + assert!(!snap(&u)); + assert_eq!(toast(&u), "Snap to pixel grid off"); + press(&mut u, Key::Quote, cmd() | Modifiers::SHIFT); + assert!(snap(&u)); + assert_eq!(toast(&u), "Snap to pixel grid on"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..c89b20e1a 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (Shift+Cmd/Ctrl+' says at the bottom of the window whether snapping to the pixel grid is now on or off; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-24 | patch | M3: Shift+Cmd/Ctrl+' turned Snap to pixel grid on or off without a sign, since nothing on the canvas changes until the next drag. A notice at the bottom now says "Snap to pixel grid on" or "off", from the shortcut, the menu and the Preferences row alike. Test: `shortcut_keys_tests::shift_cmd_quote_says_whether_snapping_to_the_pixel_grid_is_on`. | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From c8bcd4ae484faead3d576e796a8113ad3e8b5cd4 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:31:53 -0500 Subject: [PATCH 25/36] M4: Paste properties keeps a layer's styles and variables Copy properties took the values and left behind where they come from: a frame filled from a colour variable or a fill style pasted a plain, unlinked colour, and the pasted layer's own bindings stayed, so a bound radius kept its variable's value over the pasted one. It now also carries the fill, stroke, effect, grid and text style links, the variables bound to what it copies (not sizes, auto layout spacing, visibility or text content) and a frame's layout grids. The pasted layer's bindings on those give way. A style or variable the target file lacks (a copy from another tab) is left out and its values pasted, so the paste never fails on a missing link. Layout grids coming along with a frame is not measured in Figma. --- crates/engine/src/cmd/edit/clipboard.rs | 67 ++++++++++++++++-- crates/engine/src/lib.rs | 2 + crates/engine/src/paste_properties_tests.rs | 77 +++++++++++++++++++++ docs/ui-parity.md | 3 +- 4 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 crates/engine/src/paste_properties_tests.rs diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 09c79190b..8b04f7d95 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -417,7 +417,19 @@ pub(super) fn copy_props_of(doc: &Document, id: NodeId) -> Value { v["cornerRadius"] = json!(n.corners.radii); v["cornerSmoothing"] = json!(n.corners.smoothing); } + // A frame's layout grids go with its look, as its fills do. + if n.kind.is_frame_like() { + v["grids"] = json!(n.grids); + v["gridStyle"] = json!(n.styles.grid); + } + // The links behind the values: the styles and the variables they come from, so the pasted + // layer follows them as the copied one does. + v["fillStyle"] = json!(n.styles.fill); + v["strokeStyle"] = json!(n.styles.stroke); + v["effectStyle"] = json!(n.styles.effect); + v["boundVariables"] = Value::Object(n.bound.iter().filter(|(f, _)| copied_binding(f)).map(|(f, v)| (f.clone(), json!(v))).collect()); if let NodeKind::Text(t) = &n.kind { + v["textStyle"] = json!(n.styles.text); v["fontFamily"] = json!(t.style.font_family); v["fontStyle"] = json!(t.style.font_style); v["fontSize"] = json!(t.style.font_size); @@ -439,17 +451,60 @@ pub(super) fn copy_props(s: &mut Session, p: &Value) -> Result { /// properties only to text, the corners only to a layer with corners. pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, props: &Value) -> Result<()> { let mut m = props.as_object().cloned().unwrap_or_default(); - let is_text = matches!(doc.get(id)?.kind, NodeKind::Text(_)); - if !is_text { - m.retain(|k, _| !k.starts_with("font") && k != "lineHeight" && k != "letterSpacing"); + let n = doc.get(id)?; + let (is_text, corners, frame) = (matches!(n.kind, NodeKind::Text(_)), n.kind.has_corner_radius(), n.kind.is_frame_like()); + let takes = |k: &str| { + let text = k.starts_with("font") || k.starts_with("paragraph") || matches!(k, "lineHeight" | "letterSpacing" | "textStyle"); + let corner = k == "cornerSmoothing" || k.ends_with("Radius"); + let grid = k == "gridStyle" || k == "grids" || k.starts_with("grids/"); + (is_text || !text) && (corners || !corner) && (frame || !grid) + }; + m.retain(|k, _| takes(k)); + // A style or variable of another file (the copy came from another tab) isn't here to link to: + // the values it gave are pasted without the link. + let here = |v: &Value| v.as_str().is_none_or(|sid| doc.style(sid).is_some()); + m.retain(|k, v| !k.ends_with("Style") || k.starts_with("font") || here(v)); + if let Some(Value::Object(copied)) = m.get_mut("boundVariables") { + copied.retain(|_, v| v.as_str().is_some_and(|vid| doc.variables.get_by_id(vid).is_some())); } - if !doc.get(id)?.kind.has_corner_radius() { - m.remove("cornerRadius"); - m.remove("cornerSmoothing"); + // The layer's own bindings on what is pasted give way to the copied layer's: kept, a binding + // would hold the old value over the pasted one. + if let Some(Value::Object(copied)) = m.get("boundVariables") { + let mut bound: serde_json::Map = + n.bound.keys().filter(|f| copied_binding(f) && takes(f)).map(|f| (f.clone(), Value::Null)).collect(); + bound.extend(copied.iter().filter(|(f, _)| takes(f)).map(|(f, v)| (f.clone(), v.clone()))); + m.insert("boundVariables".into(), Value::Object(bound)); } crate::cmd::props::apply(cmd, doc, id, &m) } +/// Whether a variable bound to `field` goes with the properties [`copy_props_of`] copies: not a +/// size, auto layout spacing, visibility or text content. +fn copied_binding(field: &str) -> bool { + !matches!( + field, + "width" + | "height" + | "minWidth" + | "maxWidth" + | "minHeight" + | "maxHeight" + | "gap" + | "columnGap" + | "rowGap" + | "crossGap" + | "padding" + | "paddingHorizontal" + | "paddingVertical" + | "paddingTop" + | "paddingRight" + | "paddingBottom" + | "paddingLeft" + | "visible" + | "characters" + ) +} + pub(super) fn paste_props(s: &mut Session, p: &Value) -> Result { let props = s.clipboard.props.clone().ok_or_else(|| EngineError::Disabled("edit.pasteProperties".into(), "no copied properties".into()))?; let ids = req_targets("edit.pasteProperties", s, p)?; diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ad6bb085e..b31a109b4 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -688,6 +688,8 @@ mod widgets_tests; #[cfg(test)] mod page_view_tests; #[cfg(test)] +mod paste_properties_tests; +#[cfg(test)] mod selection_reorder_tests; #[cfg(test)] mod selection_spacing_tests; diff --git a/crates/engine/src/paste_properties_tests.rs b/crates/engine/src/paste_properties_tests.rs new file mode 100644 index 000000000..e43fe947c --- /dev/null +++ b/crates/engine/src/paste_properties_tests.rs @@ -0,0 +1,77 @@ +//! Copy properties and Paste properties (Alt+Cmd/Ctrl+C and V) carry what a layer's look comes +//! from as well as its values: its colour, effect and grid styles, the variables bound to what is +//! copied and a frame's layout grids. A link the file pasted into doesn't have is left out. + +use figcraft_doc::{LayoutGrid, NodeId}; +use serde_json::{Value, json}; + +use crate::Session; + +fn id(v: Value) -> NodeId { + NodeId(v["id"].as_u64().unwrap()) +} + +fn frame(s: &mut Session, x: f64) -> NodeId { + id(s.execute("frame.create", &json!({"x": x, "y": 0, "width": 100, "height": 100})).unwrap()) +} + +fn copy_onto(s: &mut Session, from: NodeId, to: NodeId) { + s.execute("edit.copyProperties", &json!({"id": from})).unwrap(); + s.execute("edit.pasteProperties", &json!({"ids": [to]})).unwrap(); +} + +#[test] +fn a_frame_pastes_its_styles_variables_and_layout_grids() { + let mut s = Session::new(); + let (a, b, c) = (frame(&mut s, 0.0), frame(&mut s, 200.0), frame(&mut s, 400.0)); + s.execute("variable.createCollection", &json!({"name": "Tokens"})).unwrap(); + for (name, value) in [("surface", "#FF0000"), ("other", "#0000FF")] { + s.execute("variable.create", &json!({"collection": "Tokens", "name": name, "type": "color", "value": value})).unwrap(); + } + s.execute("variable.create", &json!({"collection": "Tokens", "name": "radius", "type": "number", "value": 16})).unwrap(); + s.execute("variable.bind", &json!({"ids": [a], "field": "fills/0/color", "variable": "surface"})).unwrap(); + s.execute("variable.bind", &json!({"ids": [a], "field": "cornerRadius", "variable": "radius"})).unwrap(); + s.execute("node.set", &json!({"ids": [a], "props": {"grids": [serde_json::to_value(LayoutGrid::default()).unwrap()]}})).unwrap(); + // B is bound to another colour, which the paste replaces. + s.execute("variable.bind", &json!({"ids": [b], "field": "fills/0/color", "variable": "other"})).unwrap(); + let shadow = s.execute("style.create", &json!({"type": "effect", "name": "Shadow", "value": [{"type": "dropShadow"}]})).unwrap()["id"].clone(); + let green = s.execute("style.create", &json!({"type": "paint", "name": "Green", "value": "#00FF00"})).unwrap()["id"].clone(); + s.execute("style.apply", &json!({"ids": [c], "style": green})).unwrap(); + s.execute("style.apply", &json!({"ids": [c], "style": shadow})).unwrap(); + + copy_onto(&mut s, a, b); + let (na, nb) = (s.doc().unwrap().node(a).unwrap().clone(), s.doc().unwrap().node(b).unwrap().clone()); + assert_eq!(nb.bound.get("fills/0/color"), na.bound.get("fills/0/color"), "the fill follows the same variable"); + assert_eq!(nb.bound.get("cornerRadius"), na.bound.get("cornerRadius"), "and so do the corners"); + assert_eq!(nb.corners.radii, [16.0; 4]); + assert_eq!(nb.grids, na.grids, "a frame's layout grids come along"); + + copy_onto(&mut s, c, a); + let (na, nc) = (s.doc().unwrap().node(a).unwrap().clone(), s.doc().unwrap().node(c).unwrap().clone()); + assert_eq!(na.styles.fill, nc.styles.fill, "the fill style is linked"); + assert!(nc.styles.effect.is_some() && na.styles.effect == nc.styles.effect, "the effect style too"); + assert!(!na.bound.contains_key("fills/0/color"), "the style replaces the fill's variable"); + assert!(!na.bound.contains_key("cornerRadius"), "C's corners aren't bound, so A's aren't any more"); + assert!(na.grids.is_empty(), "nor has it layout grids"); + assert_eq!(na.fills, nc.fills); +} + +#[test] +fn links_another_file_lacks_paste_as_values() { + let mut s = Session::new(); + let a = frame(&mut s, 0.0); + s.execute("variable.createCollection", &json!({"name": "Tokens"})).unwrap(); + s.execute("variable.create", &json!({"collection": "Tokens", "name": "surface", "type": "color", "value": "#FF0000"})).unwrap(); + s.execute("variable.bind", &json!({"ids": [a], "field": "fills/0/color", "variable": "surface"})).unwrap(); + let st = s.execute("style.create", &json!({"type": "paint", "name": "Line", "value": "#00FF00"})).unwrap()["id"].clone(); + s.execute("node.set", &json!({"ids": [a], "props": {"strokes": [{"type": "solid", "color": "#000000"}]}})).unwrap(); + s.execute("style.apply", &json!({"ids": [a], "style": st, "target": "stroke"})).unwrap(); + s.execute("edit.copyProperties", &json!({"id": a})).unwrap(); + let copied = s.doc().unwrap().node(a).unwrap().clone(); + s.execute("file.new", &json!({})).unwrap(); + let b = frame(&mut s, 0.0); + s.execute("edit.pasteProperties", &json!({"ids": [b]})).unwrap(); + let nb = s.doc().unwrap().node(b).unwrap(); + assert_eq!((nb.fills.clone(), nb.strokes.clone()), (copied.fills, copied.strokes), "the values arrive"); + assert!(nb.bound.is_empty() && nb.styles.fill.is_none() && nb.styles.stroke.is_none(), "{:?} {:?}", nb.bound, nb.styles); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d756e71b0..b86f72b2b 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (Paste properties links the copied layer's colour, effect, grid and text styles and binds the variables it follows, and a frame's layout grids come along; links another file lacks paste as values; Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool handle drags pivot on the opposite handle whatever the origin, and the origin starts at the centre (measured in Figma's web app, 2026-11-09); M8: a selected polygon or star has a Count handle on the canvas, on its first point clockwise from the top; Zoom to selection leaves a 40 pt margin and clears the bottom toolbar, measured in Figma's web app; M1: Paste over selection puts the pasted layers just above the selected layer; drag modifiers compared in Figma's web app (2026-11-08): Shift locks a move to the dominant axis, Alt copies, Shift keeps a resize's ratio, Alt keeps its centre, all read afresh on every move, and FigCraft matches (Ctrl/Cmd not measurable); a mirror mode (angle, or angle and length) on a sharp point turns it smooth, as in Figma (#2110); M8: Tab while renaming the last layer wraps to the first row, measured in Figma's web app on 2026-11-12; the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -211,6 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-24 | patch | M4: Copy properties (Alt+Cmd/Ctrl+C) took a layer's values and left behind what they come from: a frame filled from a colour variable or a style pasted a plain colour, unlinked, and a pasted layer's own bindings stayed and could hold the old value over the pasted one. It now also carries the fill, stroke, effect, grid and text style links, the variables bound to what it copies (not size, auto layout spacing, visibility or text content) and a frame's layout grids; the pasted layer's bindings on those give way. A style or variable the file pasted into doesn't have (the copy came from another tab) is left out and its values pasted. Tests: `paste_properties_tests` (2). | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From e0ca0604ae1804688a47fc2536fdbed5f1e726c8 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:24:26 -0500 Subject: [PATCH 26/36] A scrolling panel menu stays open on a scroll bar click and keeps its rows' ids A click on a scrolling menu's scroll bar track scrolled it and then closed it: the menus close on any click, and egui counts the bar's click as one, so a row the click brought into view could not be picked. The menu now ignores clicks for the frame its scroll bar is clicked; row clicks and clicks outside still close it. The rows were also laid out in the scroll area's own UIs only while the menu scrolled, so their ids changed when a resized window started or stopped the scrolling, and the row the keyboard was on lost it. Both ways now lay the rows out in one UI with a scope id from the popup's. --- crates/ui-egui/src/menu_scroll_tests.rs | 54 +++++++++++++++++++++++++ crates/ui-egui/src/panels/right/menu.rs | 18 +++++++-- docs/ui-parity.md | 2 +- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/menu_scroll_tests.rs b/crates/ui-egui/src/menu_scroll_tests.rs index 8b12b2495..c58ae7dc8 100644 --- a/crates/ui-egui/src/menu_scroll_tests.rs +++ b/crates/ui-egui/src/menu_scroll_tests.rs @@ -58,3 +58,57 @@ fn a_menu_taller_than_the_window_scrolls_to_its_last_row() { let picked = coll.modes.iter().find(|m| m.name == "Mode 59").unwrap().id.clone(); assert_eq!(doc.node(page).unwrap().var_modes.get(&coll.id), Some(&picked), "the last mode is picked"); } + +/// The page's variable mode menu of a collection with `n` modes, opened; what it drew. +fn mode_menu(n: usize) -> (Ui, Vec) { + let modes: Vec = (0..n).map(|k| format!("Mode {k}")).collect(); + let mut s = Session::new(); + s.execute("variable.createCollection", &json!({"name": "Theme", "modes": modes})).unwrap(); + s.execute("select.set", &json!({"ids": []})).unwrap(); + let mut u = Ui::new(s); + let shapes = flat(&u.frame_output(vec![]).shapes); + let menu = click(&mut u, text_center(&shapes, "Auto (Mode 0)")); + (u, menu) +} + +/// A press and release of `key`, and a frame after it. +fn key(u: &mut Ui, key: egui::Key) { + for pressed in [true, false] { + u.frame(vec![Event::Key { key, physical_key: None, pressed, repeat: false, modifiers: Modifiers::NONE }]); + } + u.frame(vec![]); +} + +#[test] +fn a_click_on_the_scroll_bar_track_keeps_the_menu_open() { + let (mut u, menu) = mode_menu(60); + let first = at(&menu, " Mode 0").expect("the menu is open"); + u.ctx.enable_accesskit(); + let out = u.frame_output(vec![Event::PointerMoved(first)]); + let nodes = out.platform_output.accesskit_update.expect("an AccessKit update").nodes; + let bar = nodes + .iter() + .filter(|(_, n)| n.role() == egui::accesskit::Role::ScrollBar) + .filter_map(|(_, n)| n.bounds()) + .find(|b| b.x0 as f32 > first.x && (b.y0..b.y1).contains(&f64::from(first.y))) + .expect("the menu's scroll bar"); + let shapes = click(&mut u, Pos2::new(((bar.x0 + bar.x1) / 2.0) as f32, (bar.y1 - 10.0) as f32)); + assert!(texts(&shapes).iter().any(|(t, ..)| t.starts_with(" Mode ")), "the menu is still open"); + assert!(at(&shapes, " Mode 0").is_none_or(|p| p.y < first.y), "the click on the track scrolled the rows"); +} + +#[test] +fn the_keyboard_stays_on_its_row_when_the_window_shrinks_until_the_menu_scrolls_and_grows_back() { + let (mut u, _) = mode_menu(25); + for _ in 0..3 { + key(&mut u, egui::Key::ArrowDown); + } + let row = u.ctx.memory(|m| m.focused()).expect("a row has the keyboard"); + for height in [400.0, 900.0] { + u.screen = vec2(1440.0, height); + for _ in 0..10 { + u.frame(vec![]); + } + assert_eq!(u.ctx.memory(|m| m.focused()), Some(row), "the same row has the keyboard at a window {height} pt tall"); + } +} diff --git a/crates/ui-egui/src/panels/right/menu.rs b/crates/ui-egui/src/panels/right/menu.rs index 15c6d1af2..a6c46af61 100644 --- a/crates/ui-egui/src/panels/right/menu.rs +++ b/crates/ui-egui/src/panels/right/menu.rs @@ -89,9 +89,17 @@ impl Menu { /// Show the menu while it is open. Its rows `content` scroll with the wheel or the scroll bar /// once they were taller than the window last frame, as the main menu's do (#2217); a menu /// that fits is laid out as it is, so it still grows with its rows (a scroll area in a popup - /// would keep the popup's last height). + /// would keep the popup's last height). A click on the scroll bar scrolls and leaves the menu + /// open. The rows have the same ids scrolling or not, so the row the keyboard is on keeps it + /// when the window's height changes which of the two the menu does. pub fn show(self, content: impl FnOnce(&mut Ui) -> R) -> Option> { - self.0.show(|ui| { + let rows = self.0.get_id().with("menu_rows"); + let bar_key = rows.with("scroll_bar"); + let ctx = self.0.ctx().clone(); + let bar_clicked = ctx.data(|d| d.get_temp::(bar_key)).is_some_and(|bar| ctx.interaction_snapshot(|i| i.clicked == Some(bar))); + let popup = if bar_clicked { self.0.close_behavior(egui::PopupCloseBehavior::IgnoreClicks) } else { self.0 }; + let rows_ui = egui::UiBuilder::new().scope_id(rows); + popup.show(|ui| { let window = ui.ctx().content_rect().height(); let max_height = (window - ui.style().spacing.menu_margin.sum().y - 2.0 * MENU_WINDOW_GAP).max(0.0); let rows_height = ui.scope_id().with("menu_rows_height"); @@ -101,10 +109,12 @@ impl Menu { .id_salt("menu_rows") .max_height(max_height) .scroll_source(egui::scroll_area::ScrollSource::MOUSE_WHEEL | egui::scroll_area::ScrollSource::SCROLL_BAR) - .show(ui, content); + .show(ui, |ui| ui.scope_builder(rows_ui, content).inner); + // egui's id for a scroll area's vertical bar (a test in `menu_scroll_tests` clicks it). + ui.data_mut(|d| d.insert_temp(bar_key, out.id.with(1_usize))); (out.inner, out.content_size.y) } else { - let inner = content(ui); + let inner = ui.scope_builder(rows_ui, content).inner; let height = ui.min_rect().height(); if height > max_height { ui.ctx().request_repaint(); diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 448ce05a8..300f2b194 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -211,7 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| -| 2026-11-23 | patch | M3: a menu opened from a panel (a dropdown, a button's menu such as the Selection colors Styles menu, a row's context menu) ran past the window's bottom when it had more rows than fit, and the rows below couldn't be reached: with many colour variables the Styles menu showed only the first ones. egui moves a popup to keep it in the window but doesn't shorten one taller than the window. `menu_popup`, `context_popup` and the row context menus now return a `Menu` whose rows scroll with the wheel or the scroll bar once they were taller than the window last frame, as the main menu's do (#2217); a menu that fits is laid out as before and still grows with its rows. Test: `menu_scroll_tests::a_menu_taller_than_the_window_scrolls_to_its_last_row` (the page's variable mode menu of a collection with 60 modes). Numbers unchanged | +| 2026-11-23 | patch | M3: a menu opened from a panel (a dropdown, a button's menu such as the Selection colors Styles menu, a row's context menu) ran past the window's bottom when it had more rows than fit, and the rows below couldn't be reached: with many colour variables the Styles menu showed only the first ones. egui moves a popup to keep it in the window but doesn't shorten one taller than the window. `menu_popup`, `context_popup` and the row context menus now return a `Menu` whose rows scroll with the wheel or the scroll bar once they were taller than the window last frame, as the main menu's do (#2217); a menu that fits is laid out as before and still grows with its rows. A click on the scroll bar scrolls and leaves the menu open, and the row the keyboard is on keeps it when a resized window starts or stops the scrolling. Tests: `menu_scroll_tests` (the page's variable mode menu of a collection with 60 modes, and 25 for the resize). Numbers unchanged | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From 0ada8463ab89a3b67138d0b37598a92634742bb8 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:27:34 -0500 Subject: [PATCH 27/36] Paste over selection: absolutely positioned layers aren't in the flow Several absolutely positioned children of one auto layout frame took the flow branch, so the copies went to the last one's top-left, over it. The layout doesn't place them, so they now take the geometric branch like layers elsewhere: below the lowest, at the selection's own gap. --- crates/engine/src/cmd/edit/clipboard.rs | 8 ++++---- crates/engine/src/paste_over_tests.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 9e51d629d..bc017e333 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -415,8 +415,8 @@ pub(super) fn paste_over(s: &mut Session, _p: &Value) -> Result { /// The selected layer Paste over selection pastes after, and where the copies' top-left goes. /// -/// One layer: that layer, at its position. Several in one auto layout frame: the last of them in the -/// flow, which the layout follows. Several elsewhere: the lowest (then rightmost), with the copies +/// One layer: that layer, at its position. Several in one auto layout frame's flow (none absolutely +/// positioned): the last of them in the flow, which the layout follows. Several elsewhere: the lowest (then rightmost), with the copies /// below it, as far below as it is from the selected layers above it. A selection with nothing above /// its lowest layer is a row: the copies go right of the rightmost, as far as it is from its /// neighbour on the left. Layers that overlap every way get the copies right under the lowest. @@ -427,8 +427,8 @@ fn last_seen(doc: &Document, sel: &[NodeId]) -> Option<(NodeId, Option<(f64, f64 return Some((first, top_left(first))); } let parent = doc.node(first).and_then(|n| n.parent); - let one_flow = - parent.and_then(|p| doc.node(p)).is_some_and(|p| p.layout.is_some()) && sel.iter().all(|i| doc.node(*i).is_some_and(|n| n.parent == parent)); + let one_flow = parent.and_then(|p| doc.node(p)).is_some_and(|p| p.layout.is_some()) + && sel.iter().all(|i| doc.node(*i).is_some_and(|n| n.parent == parent && !n.child_layout.absolute)); if one_flow { let last = sel.iter().copied().max_by_key(|i| doc.index_in_parent(*i))?; return Some((last, top_left(last))); diff --git a/crates/engine/src/paste_over_tests.rs b/crates/engine/src/paste_over_tests.rs index 3aaf7fbd7..849e93ee7 100644 --- a/crates/engine/src/paste_over_tests.rs +++ b/crates/engine/src/paste_over_tests.rs @@ -78,3 +78,18 @@ fn several_overlapping_layers_get_the_copy_right_under_the_lowest() { let pasted = paste_over(&mut s, vec![b, a]); assert_eq!(top_left(&s, pasted[0]), (50.0, 130.0)); } + +#[test] +fn several_absolute_layers_of_an_auto_layout_get_the_copy_below_the_lowest() { + let mut s = Session::new(); + let rows: Vec = + (0..3).map(|k| id(&s.execute("shape.rectangle", &json!({"x": 0, "y": k * 30, "width": 40, "height": 20})).unwrap())).collect(); + s.execute("layout.add", &json!({"ids": rows, "direction": "vertical"})).unwrap(); + s.execute("node.set", &json!({"ids": rows, "props": {"absolute": true}})).unwrap(); + s.execute("edit.copy", &json!({"ids": [rows[0]]})).unwrap(); + let (x, y0) = top_left(&s, rows[1]); + let (_, y1) = top_left(&s, rows[2]); + let pasted = paste_over(&mut s, vec![rows[2], rows[0], rows[1]]); + assert_eq!(pasted.len(), 1); + assert_eq!(top_left(&s, pasted[0]), (x, y1 + 20.0 + (y1 - y0 - 20.0)), "the layout doesn't place them, so below the lowest"); +} From b237794c2eb82747d8c07936e9b692312c45d804 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:29:04 -0500 Subject: [PATCH 28/36] Paste properties unlinks a layer whose copied style is missing A copied style link the file no longer has was dropped from the paste, so the pasted layer kept its own style link. When the pasted values differ, the list sync unlinks it after the command anyway; when they match, the layer stayed linked to a style the copied layer never had. The missing link now pastes as null, the same as a copied layer with no style. --- crates/engine/src/cmd/edit/clipboard.rs | 8 ++++++-- crates/engine/src/paste_properties_tests.rs | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 8b04f7d95..cc7b772f4 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -461,9 +461,13 @@ pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, prop }; m.retain(|k, _| takes(k)); // A style or variable of another file (the copy came from another tab) isn't here to link to: - // the values it gave are pasted without the link. + // the values it gave are pasted without a link, so the layer's own link goes too. let here = |v: &Value| v.as_str().is_none_or(|sid| doc.style(sid).is_some()); - m.retain(|k, v| !k.ends_with("Style") || k.starts_with("font") || here(v)); + for (k, v) in m.iter_mut() { + if k.ends_with("Style") && !k.starts_with("font") && !here(v) { + *v = Value::Null; + } + } if let Some(Value::Object(copied)) = m.get_mut("boundVariables") { copied.retain(|_, v| v.as_str().is_some_and(|vid| doc.variables.get_by_id(vid).is_some())); } diff --git a/crates/engine/src/paste_properties_tests.rs b/crates/engine/src/paste_properties_tests.rs index e43fe947c..1315b7a72 100644 --- a/crates/engine/src/paste_properties_tests.rs +++ b/crates/engine/src/paste_properties_tests.rs @@ -75,3 +75,20 @@ fn links_another_file_lacks_paste_as_values() { assert_eq!((nb.fills.clone(), nb.strokes.clone()), (copied.fills, copied.strokes), "the values arrive"); assert!(nb.bound.is_empty() && nb.styles.fill.is_none() && nb.styles.stroke.is_none(), "{:?} {:?}", nb.bound, nb.styles); } + +#[test] +fn a_missing_style_unlinks_the_layers_own() { + let mut s = Session::new(); + let (a, b) = (frame(&mut s, 0.0), frame(&mut s, 200.0)); + // B's own style gives the same colour, so the paste changes no value that would unlink it. + let gone = s.execute("style.create", &json!({"type": "paint", "name": "Gone", "value": "#00FF00"})).unwrap()["id"].clone(); + let own = s.execute("style.create", &json!({"type": "paint", "name": "Own", "value": "#00FF00"})).unwrap()["id"].clone(); + s.execute("style.apply", &json!({"ids": [a], "style": gone, "target": "stroke"})).unwrap(); + s.execute("style.apply", &json!({"ids": [b], "style": own, "target": "stroke"})).unwrap(); + s.execute("edit.copyProperties", &json!({"id": a})).unwrap(); + s.execute("style.delete", &json!({"style": gone})).unwrap(); + + s.execute("edit.pasteProperties", &json!({"ids": [b]})).unwrap(); + let nb = s.doc().unwrap().node(b).unwrap(); + assert!(nb.styles.stroke.is_none(), "A's strokes had no style here, so B's aren't linked: {:?}", nb.styles); +} From 39405b02a644027e8ad293464a4b215466285b29 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:30:36 -0500 Subject: [PATCH 29/36] The pixel grid test checks that its lines sit on the screen's pixels The test checked only the lines' width, so it still passed with the lines placed between two screen pixels, where a one-pixel line spreads over both at half strength and no longer reads as measured. It now pans the view off whole points and checks every line's position at 1x and 2x. --- crates/ui-egui/src/pixel_grid_tests.rs | 32 ++++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/pixel_grid_tests.rs b/crates/ui-egui/src/pixel_grid_tests.rs index fbf1c3003..9333ffdc1 100644 --- a/crates/ui-egui/src/pixel_grid_tests.rs +++ b/crates/ui-egui/src/pixel_grid_tests.rs @@ -9,9 +9,10 @@ use crate::canvas::overlays::PIXEL_GRID; use crate::layers_drag_tests::Ui; use crate::live_tests::flat; -/// The width of each grid line drawn in a frame on a screen of `native` pixels per point (the -/// last of a few, for a new scale to take effect). -fn grid_lines(u: &mut Ui, native: f32) -> Vec { +/// Each grid line drawn in a frame on a screen of `native` pixels per point (the last of a few, +/// for a new scale to take effect): its width and the coordinate it runs along, its x if +/// vertical and its y if horizontal. +fn grid_lines(u: &mut Ui, native: f32) -> Vec<(f32, f32)> { let mut out = None; for _ in 0..4 { let mut raw = RawInput::default(); @@ -22,12 +23,18 @@ fn grid_lines(u: &mut Ui, native: f32) -> Vec { shapes .iter() .filter_map(|s| match s { - Shape::LineSegment { stroke, .. } if stroke.color == PIXEL_GRID => Some(stroke.width), + Shape::LineSegment { points: [a, b], stroke } if stroke.color == PIXEL_GRID => Some((stroke.width, if a.x == b.x { a.x } else { a.y })), _ => None, }) .collect() } +/// Whether every line in `lines` sits on the middle of a row or column of pixels of a screen of +/// `native` pixels per point, so it covers that one pixel and no half of two. +fn on_pixel_centres(lines: &[(f32, f32)], native: f32) -> bool { + lines.iter().all(|(_, at)| ((at * native - 0.5) - (at * native - 0.5).round()).abs() < 1e-3) +} + /// `c` drawn over a grey of `bg`, as the canvas blends it. fn over(c: Color32, bg: u8) -> f32 { let [r, _, _, a] = c.to_srgba_unmultiplied(); @@ -40,15 +47,20 @@ fn the_pixel_grid_shows_on_white_and_on_dark_one_screen_pixel_wide() { let mut s = Session::new(); s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 100, "height": 100})).unwrap(); let mut u = Ui::new(s); - u.app.session.ds_mut().unwrap().view.zoom = 8.0; - let widths = grid_lines(&mut u, 1.0); - assert!(!widths.is_empty(), "the grid draws at 800%"); - assert!(widths.iter().all(|w| *w == 1.0), "one screen pixel: {widths:?}"); + let view = &mut u.app.session.ds_mut().unwrap().view; + view.zoom = 8.0; + // A view between whole points, so the page's pixels fall between the screen's. + (view.cx, view.cy) = (50.03, 50.07); + let lines = grid_lines(&mut u, 1.0); + assert!(!lines.is_empty(), "the grid draws at 800%"); + assert!(lines.iter().all(|(w, _)| *w == 1.0), "one screen pixel: {lines:?}"); + assert!(on_pixel_centres(&lines, 1.0), "on the screen's pixels: {lines:?}"); // Measured in Figma (2026-11-24): a grid line is 242 on white and 78 on a grey of 50. assert_eq!((over(PIXEL_GRID, 255).round(), over(PIXEL_GRID, 50).round()), (242.0, 78.0)); // On a 2x screen the lines stay one of its pixels wide. - let widths = grid_lines(&mut u, 2.0); - assert!(!widths.is_empty() && widths.iter().all(|w| *w == 0.5), "{widths:?}"); + let lines = grid_lines(&mut u, 2.0); + assert!(!lines.is_empty() && lines.iter().all(|(w, _)| *w == 0.5), "{lines:?}"); + assert!(on_pixel_centres(&lines, 2.0), "on the 2x screen's pixels: {lines:?}"); u.app.session.ds_mut().unwrap().view.zoom = 3.0; assert!(grid_lines(&mut u, 2.0).is_empty(), "no grid below 400%"); } From 58b24d7faac48485bc321490241089f8d4a6e954 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:31:17 -0500 Subject: [PATCH 30/36] Paste properties keeps bindings on what the copy doesn't carry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pasted layer's bindings gave way on every property it could take, not only on those the copy carries: frame properties pasted onto a text layer removed its font size variable while leaving the font size, and a copy without corners did the same to a bound radius. A binding now gives way only where the copy sets that property. Layout grid bindings are keyed `layoutGrids/…`, not `grids/…`, so a frame's grid bindings also went to layers that take no grids. --- crates/engine/src/cmd/edit/clipboard.rs | 23 ++++++++++++++++++--- crates/engine/src/paste_properties_tests.rs | 15 ++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index cc7b772f4..993521ffe 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -456,7 +456,7 @@ pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, prop let takes = |k: &str| { let text = k.starts_with("font") || k.starts_with("paragraph") || matches!(k, "lineHeight" | "letterSpacing" | "textStyle"); let corner = k == "cornerSmoothing" || k.ends_with("Radius"); - let grid = k == "gridStyle" || k == "grids" || k.starts_with("grids/"); + let grid = k == "gridStyle" || k == "grids" || k.starts_with("layoutGrids/"); (is_text || !text) && (corners || !corner) && (frame || !grid) }; m.retain(|k, _| takes(k)); @@ -472,16 +472,33 @@ pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, prop copied.retain(|_, v| v.as_str().is_some_and(|vid| doc.variables.get_by_id(vid).is_some())); } // The layer's own bindings on what is pasted give way to the copied layer's: kept, a binding - // would hold the old value over the pasted one. + // would hold the old value over the pasted one. A binding on what the copy doesn't carry (a + // text layer's font size, pasted from a frame) stays. if let Some(Value::Object(copied)) = m.get("boundVariables") { let mut bound: serde_json::Map = - n.bound.keys().filter(|f| copied_binding(f) && takes(f)).map(|f| (f.clone(), Value::Null)).collect(); + n.bound.keys().filter(|f| copied_binding(f) && m.contains_key(pasted_key(f))).map(|f| (f.clone(), Value::Null)).collect(); bound.extend(copied.iter().filter(|(f, _)| takes(f)).map(|(f, v)| (f.clone(), v.clone()))); m.insert("boundVariables".into(), Value::Object(bound)); } crate::cmd::props::apply(cmd, doc, id, &m) } +/// The key of the properties [`copy_props_of`] copies that sets what a variable bound to `field` +/// sets: a corner's radius is `cornerRadius`, a side's stroke weight `strokeWeight`, the font +/// weight `fontStyle`, a layout grid's field `grids` and a paint's or effect's field its list. +fn pasted_key(field: &str) -> &str { + match field { + "topLeftRadius" | "topRightRadius" | "bottomRightRadius" | "bottomLeftRadius" => "cornerRadius", + f if crate::cmd::props::STROKE_SIDES.contains(&f) => "strokeWeight", + "fontWeight" => "fontStyle", + f => match f.split_once('/') { + Some(("layoutGrids", _)) => "grids", + Some((list, _)) => list, + None => f, + }, + } +} + /// Whether a variable bound to `field` goes with the properties [`copy_props_of`] copies: not a /// size, auto layout spacing, visibility or text content. fn copied_binding(field: &str) -> bool { diff --git a/crates/engine/src/paste_properties_tests.rs b/crates/engine/src/paste_properties_tests.rs index 1315b7a72..d77891c14 100644 --- a/crates/engine/src/paste_properties_tests.rs +++ b/crates/engine/src/paste_properties_tests.rs @@ -92,3 +92,18 @@ fn a_missing_style_unlinks_the_layers_own() { let nb = s.doc().unwrap().node(b).unwrap(); assert!(nb.styles.stroke.is_none(), "A's strokes had no style here, so B's aren't linked: {:?}", nb.styles); } + +#[test] +fn a_binding_on_what_the_copy_doesnt_carry_stays() { + let mut s = Session::new(); + let a = frame(&mut s, 0.0); + let t = id(s.execute("text.create", &json!({"text": "Hi", "x": 0, "y": 200})).unwrap()); + s.execute("variable.createCollection", &json!({"name": "Tokens"})).unwrap(); + s.execute("variable.create", &json!({"collection": "Tokens", "name": "body", "type": "number", "value": 18})).unwrap(); + s.execute("variable.bind", &json!({"ids": [t], "field": "fontSize", "variable": "body"})).unwrap(); + let before = s.doc().unwrap().node(t).unwrap().bound.get("fontSize").cloned(); + + copy_onto(&mut s, a, t); + let nt = s.doc().unwrap().node(t).unwrap(); + assert!(before.is_some() && nt.bound.get("fontSize") == before.as_ref(), "a frame carries no font size: {:?}", nt.bound); +} From 35ca50280f3ac6ff22ce5d277aa3a5319090ae8b Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:37:06 -0500 Subject: [PATCH 31/36] Paste properties into another file pastes no links Whether a copied style or variable was there to link to was decided by its id, and ids are numbered per file: the first style of every file is S:1. Pasted into another file that had styles or variables of its own, the copy linked to whichever of them shared the copied id and took its values instead of the copied ones. The test passed only because its second file had none. Copy properties now records the file it copied from, and a paste into another file drops every style and variable link: the values paste unlinked and the layer's own links on them go. The id check stays for a style deleted since the copy. --- crates/engine/src/cmd/edit/clipboard.rs | 28 ++++++++++++++++++--- crates/engine/src/paste_properties_tests.rs | 7 ++++++ crates/engine/src/prefs.rs | 3 +++ docs/ui-parity.md | 2 +- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 993521ffe..ff54c9ac2 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -127,6 +127,7 @@ pub(super) fn paste_design_layers(s: &mut Session, p: &Value) -> Result { // A design-app paste replaces the copied layers, not the copied rows: a `fill.copy` before it // still pastes afterwards. let props = s.clipboard.props.take(); + let props_source_doc = s.clipboard.props_source_doc; let paint = s.clipboard.paint.take(); let stroke = s.clipboard.stroke.take(); let paint_images = std::mem::take(&mut s.clipboard.paint_images); @@ -138,6 +139,7 @@ pub(super) fn paste_design_layers(s: &mut Session, p: &Value) -> Result { nodes, images, props, + props_source_doc, paint, stroke, paint_images, @@ -444,9 +446,26 @@ pub(super) fn copy_props(s: &mut Session, p: &Value) -> Result { let id = targets(s, p).first().copied().ok_or_else(|| bad("edit.copyProperties", "select one layer"))?; let v = copy_props_of(s.doc()?, id); s.clipboard.props = Some(v.clone()); + s.clipboard.props_source_doc = s.ds()?.uid; Ok(v) } +/// Copied properties `props` without their style and variable links, for a paste into another +/// file: the copied ids name the source file's styles and variables, and the same ids here can +/// name unrelated ones. The values paste unlinked, and the layer's own links on them go. +fn without_links(mut props: Value) -> Value { + if let Some(m) = props.as_object_mut() { + for (k, v) in m.iter_mut() { + if k.ends_with("Style") && !k.starts_with("font") { + *v = Value::Null; + } else if k == "boundVariables" { + *v = json!({}); + } + } + } + props +} + /// Give layer `id` the properties [`copy_props_of`] copied (`props`), those it can take: the text /// properties only to text, the corners only to a layer with corners. pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, props: &Value) -> Result<()> { @@ -460,8 +479,8 @@ pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, prop (is_text || !text) && (corners || !corner) && (frame || !grid) }; m.retain(|k, _| takes(k)); - // A style or variable of another file (the copy came from another tab) isn't here to link to: - // the values it gave are pasted without a link, so the layer's own link goes too. + // A style or variable the file doesn't have (deleted since the copy) isn't here to link to: the + // values it gave are pasted without a link, so the layer's own link goes too. let here = |v: &Value| v.as_str().is_none_or(|sid| doc.style(sid).is_some()); for (k, v) in m.iter_mut() { if k.ends_with("Style") && !k.starts_with("font") && !here(v) { @@ -527,7 +546,10 @@ fn copied_binding(field: &str) -> bool { } pub(super) fn paste_props(s: &mut Session, p: &Value) -> Result { - let props = s.clipboard.props.clone().ok_or_else(|| EngineError::Disabled("edit.pasteProperties".into(), "no copied properties".into()))?; + let mut props = s.clipboard.props.clone().ok_or_else(|| EngineError::Disabled("edit.pasteProperties".into(), "no copied properties".into()))?; + if s.ds()?.uid != s.clipboard.props_source_doc { + props = without_links(props); + } let ids = req_targets("edit.pasteProperties", s, p)?; let doc = s.doc_mut()?; for i in ids { diff --git a/crates/engine/src/paste_properties_tests.rs b/crates/engine/src/paste_properties_tests.rs index d77891c14..c7d696ddd 100644 --- a/crates/engine/src/paste_properties_tests.rs +++ b/crates/engine/src/paste_properties_tests.rs @@ -70,6 +70,13 @@ fn links_another_file_lacks_paste_as_values() { let copied = s.doc().unwrap().node(a).unwrap().clone(); s.execute("file.new", &json!({})).unwrap(); let b = frame(&mut s, 0.0); + // This file's own style and variable come out with the copied ids: they are not the copied ones. + s.execute("variable.createCollection", &json!({"name": "Theirs"})).unwrap(); + s.execute("variable.create", &json!({"collection": "Theirs", "name": "ink", "type": "color", "value": "#0000FF"})).unwrap(); + s.execute("style.create", &json!({"type": "paint", "name": "Ink", "value": "#0000FF"})).unwrap(); + let doc = s.doc().unwrap(); + let vid = copied.bound["fills/0/color"].as_str(); + assert!(doc.style(st.as_str().unwrap()).is_some() && doc.variables.get_by_id(vid).is_some(), "the ids are taken here"); s.execute("edit.pasteProperties", &json!({"ids": [b]})).unwrap(); let nb = s.doc().unwrap().node(b).unwrap(); assert_eq!((nb.fills.clone(), nb.strokes.clone()), (copied.fills, copied.strokes), "the values arrive"); diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 4225963f5..ac6ea0c2f 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -197,6 +197,9 @@ pub struct Clipboard { pub images: std::collections::BTreeMap, /// Copied properties (Copy properties / Paste properties). pub props: Option, + /// The file the copied properties came from: their style and variable ids name its styles and + /// variables, and in another file the same ids can name unrelated ones. + pub props_source_doc: u64, /// A copied fill or stroke row (`fill.copy`, `stroke.copy`): whether it's a fill, and the paint. pub paint: Option<(bool, figcraft_color::Paint)>, /// The stroke settings (`weight`, alignment, sides…) copied with a stroke's paint. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index b86f72b2b..003f59da7 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -211,7 +211,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| -| 2026-11-24 | patch | M4: Copy properties (Alt+Cmd/Ctrl+C) took a layer's values and left behind what they come from: a frame filled from a colour variable or a style pasted a plain colour, unlinked, and a pasted layer's own bindings stayed and could hold the old value over the pasted one. It now also carries the fill, stroke, effect, grid and text style links, the variables bound to what it copies (not size, auto layout spacing, visibility or text content) and a frame's layout grids; the pasted layer's bindings on those give way. A style or variable the file pasted into doesn't have (the copy came from another tab) is left out and its values pasted. Tests: `paste_properties_tests` (2). | +| 2026-11-24 | patch | M4: Copy properties (Alt+Cmd/Ctrl+C) took a layer's values and left behind what they come from: a frame filled from a colour variable or a style pasted a plain colour, unlinked, and a pasted layer's own bindings stayed and could hold the old value over the pasted one. It now also carries the fill, stroke, effect, grid and text style links, the variables bound to what it copies (not size, auto layout spacing, visibility or text content) and a frame's layout grids; the pasted layer's bindings on what the copy carries give way, others stay. Pasted into another file (the copy came from another tab), or after its style was deleted, a link is left out, its values pasted and the layer's own link on them dropped. Tests: `paste_properties_tests` (4). | | 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. | | 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. | | 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. | From e8057eeaefc76799452189cc026c745fe8fd57f5 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:42:45 -0500 Subject: [PATCH 32/36] A main the library holds only for an offered component pastes as a copy published_main took any main the library's manifest lists as published. The manifest also lists the components offered ones use, hidden from publishing included, with published false, so such a hidden main pasted into another file became an instance of the library's copy. It now has to be offered itself, and otherwise pastes as a copy of itself, as a hidden component the library doesn't hold already did. Instances pasted from the library file still take such a main from the library, since an offered component brings it along. --- crates/engine/src/assets/library.rs | 7 +++++-- crates/engine/src/assets/library/tests.rs | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/assets/library.rs b/crates/engine/src/assets/library.rs index 99f4b07dd..c557bdcf7 100644 --- a/crates/engine/src/assets/library.rs +++ b/crates/engine/src/assets/library.rs @@ -1485,10 +1485,13 @@ fn from_published(doc: &mut Document, src: &Document, src_path: Option<&str>, ro /// The main in `doc` that pasting main component `main`, copied from another document `src`, /// makes an instance of: `doc`'s copy of it from the library `src` publishes, as -/// [`adopt_pasted`] uses for instances. `None` when `src` doesn't publish it, so the paste copies -/// the main itself. +/// [`adopt_pasted`] uses for instances. `None` when `src` doesn't offer it, so the paste copies +/// the main itself: also when the library holds it only because an offered component uses it. pub fn published_main(doc: &mut Document, src: &Document, src_path: Option<&str>, main: NodeId) -> Result> { let Some(root) = asset_root(src, main) else { return Ok(None) }; + if !src.published.as_ref().and_then(|l| l.manifest.component(root)).is_some_and(|a| a.published) { + return Ok(None); + } Ok(from_published(doc, src, src_path, &[root])?.get(&main).copied()) } diff --git a/crates/engine/src/assets/library/tests.rs b/crates/engine/src/assets/library/tests.rs index ca4233381..5edee822f 100644 --- a/crates/engine/src/assets/library/tests.rs +++ b/crates/engine/src/assets/library/tests.rs @@ -698,7 +698,8 @@ fn library_links_follow_a_moved_folder() { /// A main component copied from a library file and pasted into another file is an instance of it /// from that library, which gets enabled, as pasting an instance of it is; a variant is an instance -/// of that variant. A component the library doesn't offer pastes as a copy of itself. +/// of that variant. A component the library doesn't offer pastes as a copy of itself, also one the +/// library holds because an offered component uses it. #[test] fn a_main_pasted_from_its_library_file_is_an_instance_of_it() { let d = dir("paste-main"); @@ -719,7 +720,13 @@ fn a_main_pasted_from_its_library_file_is_an_instance_of_it() { ex(&mut s, "component.combineVariants", json!({"ids": sizes.clone()})); let spare = idv(&ex(&mut s, "frame.create", json!({"x": 300, "y": 300, "width": 10, "height": 10, "name": "_Spare"}))); let spare = idv(&ex(&mut s, "component.create", json!({"ids": [spare]}))); + let icon = idv(&ex(&mut s, "frame.create", json!({"x": 400, "y": 300, "width": 10, "height": 10, "name": "_Icon"}))); + let icon = idv(&ex(&mut s, "component.create", json!({"ids": [icon]}))); + let badge = idv(&ex(&mut s, "frame.create", json!({"x": 500, "y": 300, "width": 30, "height": 30, "name": "Badge"}))); + ex(&mut s, "instance.create", json!({"component": icon, "x": 5, "y": 5, "parent": badge})); + ex(&mut s, "component.create", json!({"ids": [badge]})); let lid = publish_to(&mut s, &lib_path); + assert!(s.doc().unwrap().published.as_ref().unwrap().manifest.component(icon).is_some_and(|a| !a.published)); let at = s.doc().unwrap().world_bounds(k.button).unwrap(); ex(&mut s, "file.new", json!({"name": "Design"})); let paste = |s: &mut Session, main: NodeId| -> NodeId { @@ -751,6 +758,9 @@ fn a_main_pasted_from_its_library_file_is_an_instance_of_it() { let copy = paste(&mut s, spare); assert!(matches!(node(&s, copy).kind, NodeKind::Component { .. }), "not offered by the library: a copy"); assert!(!s.doc().unwrap().is_remote(copy)); + let icon_copy = paste(&mut s, icon); + assert!(matches!(node(&s, icon_copy).kind, NodeKind::Component { .. }), "only used by an offered component: a copy"); + assert!(!s.doc().unwrap().is_remote(icon_copy)); healthy(&s); let _ = std::fs::remove_dir_all(d); } From a69319e8bd1631d87d910d95792628ea628fb9a8 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:46:30 -0500 Subject: [PATCH 33/36] Frames resized together or dropped into a frame land on whole pixels too Resizing several frames at once rounded only the pointer, and each frame took its share of the scale as is: two 100 wide frames resized from 300 to 400 became 133.33 wide, one at 266.67. Each one now has its edges on the nearest whole pixel of its parent, so the box still follows the drag, at most half a pixel off per edge, and is never less than a pixel. A frame moved into another frame was settled on whole pixels of the parent it was dragged in, then reparented on the drop with its place on the page kept, so in a frame off the grid it sat at .5 in it. It is settled again in the frame it is dropped into. --- crates/engine/src/canvas/tools/drag.rs | 29 ++++++++++++++++++- crates/engine/src/canvas/tools/draw.rs | 5 ++++ .../engine/src/transform_behaviour_tests.rs | 25 ++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/canvas/tools/drag.rs b/crates/engine/src/canvas/tools/drag.rs index 75e8e8c44..36c38f45d 100644 --- a/crates/engine/src/canvas/tools/drag.rs +++ b/crates/engine/src/canvas/tools/drag.rs @@ -671,8 +671,16 @@ impl Session { let lin = (mirror * local).with_translation(Vec2::ZERO); let origin = Point::new(x0 + center.x * sx, y0 + center.y * sy) - lin * Point::new(w2 / 2.0, h2 / 2.0); let kept = if keeps(doc, *id) { crate::cmd::props::children_worlds(doc, *id) } else { Vec::new() }; - doc.set_world_transform(*id, frame * lin.with_translation(origin))?; + let (t, w2, h2) = if boards { + on_whole_pixels(doc, *id, frame * lin.with_translation(origin), w2, h2) + } else { + (frame * lin.with_translation(origin), w2, h2) + }; + doc.set_world_transform(*id, t)?; crate::cmd::props::resize_node(doc, *id, w2, h2)?; + if boards { + crate::snap::settle_on_pixels(doc, *id)?; + } crate::cmd::props::restore_worlds(doc, &kept)?; } Ok(()) @@ -707,6 +715,25 @@ impl Session { } } +/// `world` and the size `w` x `h` a layer of a resized selection takes, moved so its box in its +/// parent has its edges on whole pixels, each on the nearest one and the box at least a pixel +/// wide: a frame resized with others lands on whole pixels as one resized alone does. A layer +/// turned or scaled in its parent keeps them. +fn on_whole_pixels(doc: &Document, id: NodeId, world: Affine, w: f64, h: f64) -> (Affine, f64, f64) { + let pw = doc.node(id).and_then(|n| n.parent).map_or(Affine::IDENTITY, |p| doc.world_transform(p)); + let local = pw.inverse() * world; + let [a, b, c, d, e, f] = local.as_coeffs(); + if !crate::guides::axis_aligned(local) || (a.abs() - 1.0).abs() > 1e-9 || (d.abs() - 1.0).abs() > 1e-9 { + return (world, w, h); + } + let edges = |at: f64, flip: bool, len: f64| if flip { (at - len, at) } else { (at, at + len) }; + let ((x0, x1), (y0, y1)) = (edges(e, a < 0.0, w), edges(f, d < 0.0, h)); + let (x0, y0) = (x0.round(), y0.round()); + let (w, h) = ((x1.round() - x0).max(1.0), (y1.round() - y0).max(1.0)); + let (e, f) = (if a < 0.0 { x0 + w } else { x0 }, if d < 0.0 { y0 + h } else { y0 }); + (pw * Affine::new([a, b, c, d, e, f]), w, h) +} + /// Moving `moving` by the same offset moves nothing else and changes nothing about them but where /// they are: none is inside another (it would move twice) or placed by its parent's auto layout /// (the layout would put it back, or close the gap it leaves). diff --git a/crates/engine/src/canvas/tools/draw.rs b/crates/engine/src/canvas/tools/draw.rs index 867567618..0eaee1cae 100644 --- a/crates/engine/src/canvas/tools/draw.rs +++ b/crates/engine/src/canvas/tools/draw.rs @@ -165,6 +165,11 @@ impl Session { } // A layer can't go into itself; it stays where it is. let _ = d.reparent(*m, target, None); + // Frames, sections and components land on whole pixels of the frame + // they are dropped into too. + if d.node(*m).is_some_and(crate::snap::always_on_pixels) { + crate::snap::settle_on_pixels(d, *m)?; + } } crate::normalize(ds.doc_mut(), &before); } diff --git a/crates/engine/src/transform_behaviour_tests.rs b/crates/engine/src/transform_behaviour_tests.rs index e62024380..a4fa9289c 100644 --- a/crates/engine/src/transform_behaviour_tests.rs +++ b/crates/engine/src/transform_behaviour_tests.rs @@ -837,6 +837,31 @@ fn frames_land_on_whole_pixels_whatever_they_snap_to() { assert!(near(bounds(&s, r).x0, 110.7), "{:?}", bounds(&s, r)); } +#[test] +fn frames_resized_together_each_land_on_whole_pixels() { + let mut s = session(); + let frame = |s: &mut Session, x: f64| id(&ex(s, "frame.create", json!({"x": x, "y": 0, "width": 100, "height": 100}))); + let (a, b) = (frame(&mut s, 0.0), frame(&mut s, 200.0)); + ex(&mut s, "select.set", json!({"ids": [a, b]})); + // 300 wide to 400: a third more, so each frame alone would be 133.33 wide. + drag(&mut s, Point::new(300.0, 100.0), Point::new(400.0, 100.0), Mods::default()); + assert_eq!(bounds(&s, a), Rect::new(0.0, 0.0, 133.0, 100.0)); + assert_eq!(bounds(&s, b), Rect::new(267.0, 0.0, 400.0, 100.0)); +} + +#[test] +fn a_frame_dropped_into_a_frame_off_the_pixel_grid_lands_on_its_whole_pixels() { + let mut s = session(); + let target = id(&ex(&mut s, "frame.create", json!({"x": 300.5, "y": 0.5, "width": 300, "height": 300}))); + let f = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 50, "height": 50}))); + ex(&mut s, "select.set", json!({"ids": [f]})); + drag(&mut s, Point::new(25.0, 25.0), Point::new(425.0, 125.0), Mods::default()); + let n = s.doc().unwrap().node(f).unwrap().clone(); + assert_eq!(n.parent, Some(target)); + let [.., x, y] = n.transform.as_coeffs(); + assert_eq!((x.fract(), y.fract()), (0.0, 0.0), "at {x}, {y} in the frame"); +} + #[test] fn corner_cursors_stay_diagonal_whatever_the_proportions() { let mut s = session(); From 16976d07c37f0e65a20a4e4fd58959ff11348ab9 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:52:46 -0500 Subject: [PATCH 34/36] A text layer's name counts as unique only over all of a variant's text layers The name fallback counted names after path matching had taken its layers, so with a/Label and b/Label switching to a/Label and c/Label, a/Label matched by path and the two leftovers looked unique: text typed into b/Label landed in c/Label, although Label names two layers on each side. Names are now counted over every text layer outside nested instances, matched ones too, and only then limited to the unmatched ones, as the rule says: exactly one layer of that name on each side. --- crates/engine/src/assets/components/sync.rs | 24 +++++++++++++------- crates/engine/src/assets/components/tests.rs | 13 +++++++++-- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/assets/components/sync.rs b/crates/engine/src/assets/components/sync.rs index d0e7a6eac..7ef3fed8c 100644 --- a/crates/engine/src/assets/components/sync.rs +++ b/crates/engine/src/assets/components/sync.rs @@ -115,15 +115,23 @@ fn match_layers( } m.map.insert(*s, nid); } - match_text_by_name(doc, inst, component, old, &mut m); + match_text_by_name(doc, inst, component, src, old, &mut m); m } /// Main text layers nothing matched take the unmatched old text layer of the same name, when /// exactly one of each has it: text typed into an instance stays when it switches to a variant that /// nests the same text layer in other frames (its name path differs). Only layers outside nested -/// instances, which rebuild from their own mains. -fn match_text_by_name(doc: &Document, inst: NodeId, component: NodeId, old: &BTreeMap>, m: &mut Matched) { +/// instances, which rebuild from their own mains. Names are counted over all those text layers, +/// matched ones too, so a name two layers share on either side never pairs by elimination. +fn match_text_by_name( + doc: &Document, + inst: NodeId, + component: NodeId, + src: &[NodeId], + old: &BTreeMap>, + m: &mut Matched, +) { fn unique(pairs: impl Iterator) -> BTreeMap { let mut seen: BTreeMap> = BTreeMap::new(); for (k, id) in pairs { @@ -132,19 +140,19 @@ fn match_text_by_name(doc: &Document, inst: NodeId, component: NodeId, old: &BTr seen.into_iter().filter_map(|(k, id)| Some((k, id?))).collect() } let text = |n: &Node| matches!(n.kind, NodeKind::Text(_)); - let mains = unique( - m.fresh.iter().filter_map(|s| doc.node(*s)).filter(|s| text(s) && outside_nested(doc, s.id, component)).map(|s| (s.name.clone(), s.id)), - ); + let mut mains = + unique(src.iter().filter_map(|s| doc.node(*s)).filter(|s| text(s) && outside_nested(doc, s.id, component)).map(|s| (s.name.clone(), s.id))); + mains.retain(|_, s| m.fresh.contains(s)); if mains.is_empty() { return; } let olds = unique( old.iter() - .filter(|(id, o)| text(o) && !m.used.contains(id) && outside_nested(doc, **id, inst)) + .filter(|(id, o)| text(o) && outside_nested(doc, **id, inst)) .map(|(id, o)| (o.source.and_then(|s| doc.node(s)).map_or(&o.name, |s| &s.name).clone(), *id)), ); for (name, s) in mains { - if let Some(o) = olds.get(&name) { + if let Some(o) = olds.get(&name).filter(|o| !m.used.contains(*o)) { m.used.insert(*o); m.map.insert(s, *o); m.fresh.retain(|f| *f != s); diff --git a/crates/engine/src/assets/components/tests.rs b/crates/engine/src/assets/components/tests.rs index 6bc8e83c5..ea5542c9d 100644 --- a/crates/engine/src/assets/components/tests.rs +++ b/crates/engine/src/assets/components/tests.rs @@ -286,7 +286,8 @@ fn variant_switch_keeps_compatible_overrides() { fn typed_text_stays_across_variants_that_nest_it_differently() { let mut s = Session::new(); // Each variant's Label layers, by the frames holding them. - let shapes: [(&str, &[&[&str]]); 3] = [("Kind=Plain", &[&["text"]]), ("Kind=Boxed", &[&["div", "text"]]), ("Kind=Twice", &[&["a"], &["b"]])]; + let shapes: [(&str, &[&[&str]]); 4] = + [("Kind=Plain", &[&["text"]]), ("Kind=Boxed", &[&["div", "text"]]), ("Kind=Twice", &[&["a"], &["b"]]), ("Kind=Moved", &[&["a"], &["c"]])]; let mut labels = Vec::new(); let mut variants = Vec::new(); for (k, (name, paths)) in shapes.into_iter().enumerate() { @@ -313,8 +314,16 @@ fn typed_text_stays_across_variants_that_nest_it_differently() { ex(&mut s, "instance.setProperties", json!({"ids": [i], "properties": {"Kind": "Twice"}})); healthy(&s); - let texts: Vec = labels[2..].iter().map(|l| chars(&s, copy_of(&s, i, *l))).collect(); + let texts: Vec = labels[2..4].iter().map(|l| chars(&s, copy_of(&s, i, *l))).collect(); assert_eq!(texts, ["I agree", "I agree"], "two layers of that name: neither is the one typed into"); + + // `a › Label` matches by path; the leftover `b › Label` and `c › Label` still share a name with it. + let typed = copy_of(&s, i, labels[3]); + ex(&mut s, "text.set", json!({"id": typed, "characters": "Architect"})); + ex(&mut s, "instance.setProperties", json!({"ids": [i], "properties": {"Kind": "Moved"}})); + healthy(&s); + let texts: Vec = labels[4..].iter().map(|l| chars(&s, copy_of(&s, i, *l))).collect(); + assert_eq!(texts, ["I agree", "I agree"], "a name two layers share doesn't pair what path matching left over"); } #[test] From 09553289bafea54a4984119f46e98e42fb5cf396 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:59:18 -0500 Subject: [PATCH 35/36] Desktop: load the preferences before opening the files named on the command line The files named on the command line opened before the preferences were read, so file.open saw no kept views: such a file opened fitted instead of where it was left. It also put the file at the top of the recent files, and the preferences read just after replaced that list. --- apps/figcraft/src/main.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/figcraft/src/main.rs b/apps/figcraft/src/main.rs index b340fcbdd..c68ea4a67 100644 --- a/apps/figcraft/src/main.rs +++ b/apps/figcraft/src/main.rs @@ -200,6 +200,14 @@ fn main() -> eframe::Result { let mut session = Session::empty(); // Live sessions: the network threads wake the window when something arrives. session.live.install(Box::new(figcraft_collab_net::NetLink::new(Arc::new(wake(&ctx_slot))))); + // The preferences first: a file named on the command line opens where it was left and goes to + // the top of the recent files, and they hold the online files a recovered document may be one of. + let recovery = recovery::Shared::default(); + let svc = services::Desktop::load(recovery.clone()); + svc.follow_system_dark(wake(&ctx_slot)); + if let Some(prefs) = svc.prefs.clone() { + session.prefs = prefs; + } // A file that won't open is said in the window too: it may have been double-clicked. let mut failed_open = None; for f in &args.files { @@ -212,13 +220,6 @@ fn main() -> eframe::Result { let mut opened: Vec = session.docs.iter().map(|d| d.uid).collect(); // Documents a crashed or killed run left unsaved come back; this run keeps its own copies. let recovery_root = services::config_dir().map(|d| d.join("Recovery")); - // The preferences first: they hold the online files a recovered document may be one of. - let recovery = recovery::Shared::default(); - let svc = services::Desktop::load(recovery.clone()); - svc.follow_system_dark(wake(&ctx_slot)); - if let Some(prefs) = svc.prefs.clone() { - session.prefs = prefs; - } let recovered = recovery_root.as_deref().map(|r| recovery::recover_all(r, &mut session)).unwrap_or_default(); let mut copies = recovery_root.as_deref().and_then(recovery::Recovery::start); // Copies of online files stay until their files arrive from their servers. From 20de68e9ca10bc3b0b8c64624fc22637003e6aa3 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:59:18 -0500 Subject: [PATCH 36/36] Tests: the reopen and file view tests remove their folders when they fail too The folders were removed at each test's end only, so a failing assertion left them in the temporary directory. They are now removed on drop, as path_read_caps_tests does. --- crates/engine/src/file_views/tests.rs | 23 +++++++++++++++++----- crates/engine/src/reopen_tests.rs | 28 +++++++++++++++++++-------- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/file_views/tests.rs b/crates/engine/src/file_views/tests.rs index 1606c02ed..b7d2c9323 100644 --- a/crates/engine/src/file_views/tests.rs +++ b/crates/engine/src/file_views/tests.rs @@ -8,10 +8,26 @@ fn ex(s: &mut Session, cmd: &str, p: Value) -> Value { s.execute(cmd, &p).unwrap_or_else(|e| panic!("{cmd} {p}: {e}")) } -fn dir(name: &str) -> std::path::PathBuf { +/// A test's folder, removed when the test ends, a failing one too. +struct Dir(std::path::PathBuf); + +impl std::ops::Deref for Dir { + type Target = std::path::Path; + fn deref(&self) -> &std::path::Path { + &self.0 + } +} + +impl Drop for Dir { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.0); + } +} + +fn dir(name: &str) -> Dir { let d = std::env::temp_dir().join(format!("figcraft-file-views-{}-{name}", std::process::id())); std::fs::create_dir_all(&d).unwrap(); - d + Dir(d) } /// A saved file at `path` with two pages, each holding a rectangle, the first page shown. @@ -64,7 +80,6 @@ fn a_file_opens_again_where_it_was_left() { next.prefs = prefs; ex(&mut next, "file.open", json!({"path": path})); assert_eq!(view(&next), (second, 2010.0, 2020.0, 0.5)); - let _ = std::fs::remove_dir_all(d); } /// Quitting keeps every open file's view; a file never saved keeps none. @@ -87,7 +102,6 @@ fn quitting_keeps_each_open_files_view() { assert_eq!(view(&next), (a_page, 1.0, 2.0, 3.0)); ex(&mut next, "file.open", json!({"path": b})); assert_eq!(view(&next), (b_page, 4.0, 5.0, 0.25)); - let _ = std::fs::remove_dir_all(d); } /// A kept page the file no longer has, or a view the canvas can't show, is left out: the file @@ -106,7 +120,6 @@ fn a_view_that_no_longer_fits_the_file_is_left_out() { assert_eq!(ds.page, first); assert!(ds.fit_when_sized, "fitted as a file never left"); assert!(ds.view.cx.is_finite()); - let _ = std::fs::remove_dir_all(d); } /// The views kept are bounded, the most recently left first. diff --git a/crates/engine/src/reopen_tests.rs b/crates/engine/src/reopen_tests.rs index b02c95c90..f2e2e7a4b 100644 --- a/crates/engine/src/reopen_tests.rs +++ b/crates/engine/src/reopen_tests.rs @@ -1,19 +1,35 @@ //! The files open when the desktop app quit open again at its next start. -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use serde_json::json; use crate::Session; -fn folder(name: &str) -> PathBuf { +/// A fresh folder for a test's files, removed when the test ends, a failing one too. +struct Folder(PathBuf); + +impl std::ops::Deref for Folder { + type Target = Path; + fn deref(&self) -> &Path { + &self.0 + } +} + +impl Drop for Folder { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.0); + } +} + +fn folder(name: &str) -> Folder { let dir = std::env::temp_dir().join(format!("figcraft-reopen-{name}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); - dir + Folder(dir) } -fn saved(s: &mut Session, dir: &std::path::Path, name: &str) -> String { +fn saved(s: &mut Session, dir: &Path, name: &str) -> String { let path = dir.join(format!("{name}.figcraft")).to_string_lossy().into_owned(); s.execute("file.new", &json!({"name": name})).unwrap(); s.execute("file.save", &json!({"path": path})).unwrap(); @@ -48,7 +64,6 @@ fn the_files_open_at_quit_reopen_in_their_order_with_the_same_one_in_front() { assert!(t.reopen_files().is_empty()); assert_eq!(paths(&t), vec![Some(a), Some(b.clone()), Some(c)]); assert_eq!(t.docs[t.active].path.as_deref(), Some(b.as_str()), "B is in front again"); - let _ = std::fs::remove_dir_all(&dir); } #[test] @@ -66,7 +81,6 @@ fn a_file_gone_since_is_skipped_and_one_that_wont_open_says_why() { let failed = t.reopen_files(); assert_eq!(failed.iter().map(|(p, _)| p.clone()).collect::>(), vec![broken]); assert_eq!(paths(&t), vec![Some(kept)]); - let _ = std::fs::remove_dir_all(&dir); } #[test] @@ -84,7 +98,6 @@ fn a_file_already_open_at_start_keeps_its_one_tab() { assert!(t.reopen_files().is_empty()); assert_eq!(paths(&t), vec![Some(b), Some(a.clone())]); assert_eq!(t.docs[t.active].path.as_deref(), Some(a.as_str())); - let _ = std::fs::remove_dir_all(&dir); } #[test] @@ -99,5 +112,4 @@ fn quitting_with_nothing_open_leaves_nothing_to_reopen() { assert_eq!(s.prefs.front_file, None); let saved = serde_json::to_value(&s.prefs).unwrap(); assert!(saved.get("open_files").is_none() && saved.get("front_file").is_none(), "not written when empty"); - let _ = std::fs::remove_dir_all(&dir); }