M3: the Local variables window selects several variables with Shift and Cmd/Ctrl, and acts on them at once (#2002)

The window keeps a selection of variable ids: a click selects one row, Shift+click the range from the anchor through the rows shown, Cmd/Ctrl+click toggles a row, and Escape or a click on the empty space clears it. Selected rows use the sidebar's selected-row colour.

Right-clicking a row that is part of a selection of several offers Delete, Move to group and Scope for all of them, each sent as one command.batch so it is one undo step. Rename and value edits stay single-row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Trevor BrownandClaude Fable 5.1 committed 2026-11-05 15:54:11 -05:00
1 parent 01762dae33
commit 4fcb95eeab
6 files changed
+338 -4

No files matched your search

+2 -1
View File
@@ -2,7 +2,7 @@
**Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; 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 Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); 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; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style insLine truncated
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-05 · **Change:** minor (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 all of them in one undo step (#2002); web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; 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 Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); 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; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprLine truncated
FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow,
native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through
@@ -132,6 +132,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md).
## Progress log
- **2026-11-05** · M3, #2002: the Local variables window selects several variables with a click, Shift+click (range) and Cmd/Ctrl+click (toggle), cleared by Escape or a click on the empty space; delete, move to a group and scope act on the whole selection as one undo step (`command.batch`). Rename and value edits stay single-row.
- **2026-10-30**: M8, #1125: damaged `trak` size-table offsets are checked instead of wrapping on 32-bit targets, and an incomplete normal track is dropped entirely, never returned in part. Font indexing makes its existing bounds explicit, preserving later faces and sparse name-table reads. Synthetic regression tests in `fontdb_tests.rs`. Numbers unchanged.
- **2026-10-30** · Text style dedupe is O(spans) (M8, #1102): `shape_text` deduped spans into styles by a scan over the styles already collected — O(spans × styles), so a styled text's dedupe grew with the square of its runs (a synthetic 50k-run text with 100 alternating styles spent 7.7 ms in it). Now the last two styles again (spans run in blocks), then buckets keyed by a cheap fingerprint (family and style bytes, size bits with −0.0 folded, the enums, fill count and solid colours), each bucket resolved with the full equality: the result is the scan's, never worse than it, and O(spans) when names and sizes differ (the same synthetic text: 2.6 ms). The font-db write lock is untouched: `find()` loads faces, which needs the write. `layout_dedupe_tests`. Numbers unchanged.
- **2026-10-29** · M10: correct nine German labels in `de.toml`: gradient stops use Verlaufsstopp, OpenType ss01–ss05 use Stilsatz, and the Home-screen preference names the Startbildschirm consistently in the UI and Actions palette. This is a partial terminology pass; German remains a draft awaiting a full native-speaker review and maintainer approval. Numbers unchanged.
+6
View File
@@ -406,6 +406,12 @@ name = "English"
"Decoration style" = "Decoration style"
"Decoration" = "Decoration"
"Deep select" = "Deep select"
"Delete {n} variables" = { one = "Delete {n} variable", other = "Delete {n} variables" }
"Move out of any group" = "Move out of any group"
"Move to group {group}" = "Move to group {group}"
"Scope: all supported properties" = "Scope: all supported properties"
"Scope: hidden from pickers" = "Scope: hidden from pickers"
"Scope: only {scope}" = "Scope: only {scope}"
"Wrap style" = "Wrap style"
"Balance" = "Balance"
"Pretty" = "Pretty"
+131 -1
View File
@@ -53,6 +53,107 @@ pub struct Editor {
details: Option<String>,
/// The group the table shows ("space" or "color/brand"); None = every variable.
group: Option<String>,
/// The selected variables' ids (this file's), kept to the rows the table shows.
pub(crate) selected: Vec<String>,
/// The row a Shift+click extends from.
pub(crate) anchor: Option<String>,
/// The variable ids the table shows now, in row order (the range a Shift+click covers).
pub(crate) order: Vec<String>,
}
/// A click on row `id`: plain selects only it, Shift extends from the anchor to it through the
/// rows shown (added to the selection with Cmd/Ctrl), Cmd/Ctrl (or Shift without an anchor) toggles it.
pub(crate) fn select_clicked(st: &mut Editor, id: &str, m: egui::Modifiers) {
let pos = |x: &str| st.order.iter().position(|o| o == x);
let anchor = st.anchor.as_deref().filter(|a| st.selected.iter().any(|s| s == a)).and_then(pos);
if m.shift
&& let (Some(ai), Some(bi)) = (anchor, pos(id))
{
let (lo, hi) = (ai.min(bi), ai.max(bi));
let mut s: Vec<String> = if m.command { st.selected.clone() } else { vec![] };
for x in st.order.get(lo..=hi).unwrap_or_default() {
if !s.contains(x) {
s.push(x.clone());
}
}
st.selected = s;
} else if m.shift || m.command {
match st.selected.iter().position(|x| x == id) {
Some(i) => {
st.selected.remove(i);
}
None => st.selected.push(id.to_string()),
}
st.anchor = Some(id.to_string());
} else {
st.selected = vec![id.to_string()];
st.anchor = Some(id.to_string());
}
}
/// The variables a row's menu acts on: the whole selection when the row is part of a selection of
/// several (in table order, leaving out inherited ones, which are changed in their own collection),
/// else None.
fn bulk_ids<'a>(view: &View<'a>, st: &Editor, v: &Variable) -> Option<Vec<&'a Variable>> {
if !view.editable() || st.selected.len() < 2 || !st.selected.contains(&v.id) {
return None;
}
let list: Vec<&Variable> =
st.order.iter().filter(|id| st.selected.contains(id)).filter_map(|id| view.vars.get_by_id(id)).filter(|x| x.extends.is_none()).collect();
(list.len() > 1).then_some(list)
}
/// Run one `variable.*` command per variable as a single undo step.
fn bulk_run(app: &mut FigApp, label: &str, vars: &[&Variable], step: impl Fn(&Variable) -> Option<(&'static str, Value)>) {
let steps: Vec<Value> = vars.iter().filter_map(|v| step(v)).map(|(command, params)| json!({"command": command, "params": params})).collect();
if !steps.is_empty() {
app.run("command.batch", json!({"label": label, "commands": steps}));
}
}
/// The context menu of a row that is part of a selection of several: delete, move to a group and
/// scope act on all of them.
fn bulk_menu(app: &mut FigApp, ui: &mut Ui, coll_groups: &[String], vars: &[&Variable]) {
let n = vars.len();
if menu_item(ui, &trn("Delete {n} variables", n, &[]), "") {
bulk_run(app, "Delete variables", vars, |v| Some(("variable.delete", json!({"variable": v.id}))));
ui.close();
}
let moves = std::iter::once(None).chain(coll_groups.iter().map(|g| Some(g.as_str())));
for g in moves {
let label = g.map_or_else(|| tr("Move out of any group").to_string(), |g| trf("Move to group {group}", &[("group", &g)]));
if menu_item(ui, &label, "") {
bulk_run(app, "Move variables", vars, |v| {
let short = v.name.rsplit('/').next().unwrap_or(&v.name);
let name = g.map_or_else(|| short.to_string(), |g| format!("{g}/{short}"));
(name != v.name).then(|| ("variable.update", json!({"variable": v.id, "name": name})))
});
ui.close();
}
}
let mut scopes: Vec<(&'static str, &'static str)> = Vec::new();
for v in vars {
for s in scopes_for(v.kind) {
if !scopes.contains(s) {
scopes.push(*s);
}
}
}
let set = |app: &mut FigApp, label: &str, value: Option<&'static str>, ui: &mut Ui| {
if menu_item(ui, label, "") {
bulk_run(app, "Change scope", vars, |v| match value {
None => Some(("variable.update", json!({"variable": v.id, "scopes": Value::Null}))),
Some("") => Some(("variable.update", json!({"variable": v.id, "scopes": []}))),
Some(s) => scopes_for(v.kind).iter().any(|(id, _)| *id == s).then(|| ("variable.update", json!({"variable": v.id, "scopes": [s]}))),
});
ui.close();
}
};
set(app, tr("Scope: all supported properties"), None, ui);
set(app, tr("Scope: hidden from pickers"), Some(""), ui);
for (id, label) in scopes {
set(app, &trf("Scope: only {scope}", &[("scope", &tr(label))]), Some(id), ui);
}
}
impl Editor {
@@ -575,6 +676,17 @@ fn table(app: &mut FigApp, ui: &mut Ui, view: &View, st: &mut Editor) {
let mut list: Vec<&Variable> =
view.in_collection(&coll.id).filter(|v| in_group(v) && (q.is_empty() || v.name.to_lowercase().contains(&q))).collect();
list.sort_by(|a, b| group_of(&a.name).cmp(group_of(&b.name)));
st.order = list.iter().map(|v| v.id.clone()).collect();
let order = st.order.clone();
st.selected.retain(|id| order.contains(id));
// Escape clears the selection (unless a field has the keyboard).
if !st.selected.is_empty()
&& st.rename.is_none()
&& !ui.ctx().egui_wants_keyboard_input()
&& ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
{
st.selected.clear();
}
let width = (NAME_W + coll.modes.len() as f32 * MODE_W + 40.0).max(ui.available_width());
egui::ScrollArea::both().id_salt("vars_table").auto_shrink([false, false]).show(ui, |ui| {
ui.spacing_mut().item_spacing = vec2(0.0, 0.0);
@@ -597,6 +709,11 @@ fn table(app: &mut FigApp, ui: &mut Ui, view: &View, st: &mut Editor) {
}
if view.editable() {
create_row(app, ui, view, coll, st);
// A click on the empty space below the rows clears the selection.
let (_, empty) = ui.allocate_exact_size(vec2(width, ui.available_height().max(24.0)), Sense::click());
if empty.clicked() {
st.selected.clear();
}
}
});
}
@@ -686,7 +803,10 @@ fn var_row(app: &mut FigApp, ui: &mut Ui, view: &View, coll: &Collection, v: &Va
let t = Tokens::get(ui.ctx());
let editable = view.editable();
let (r, resp) = ui.allocate_exact_size(vec2(width, ROW_H), Sense::click());
if resp.hovered() || (editable && st.details.as_deref() == Some(v.id.as_str())) {
let selected = editable && st.selected.contains(&v.id);
if selected {
ui.painter().rect_filled(r, CornerRadius::ZERO, t.selected_row);
} else if resp.hovered() || (editable && st.details.as_deref() == Some(v.id.as_str())) {
ui.painter().rect_filled(r, CornerRadius::ZERO, t.hover);
}
kind_glyph(ui, view.vars, v, coll, Rect::from_center_size(pos2(r.min.x + 24.0, r.center().y), vec2(14.0, 14.0)));
@@ -709,10 +829,20 @@ fn var_row(app: &mut FigApp, ui: &mut Ui, view: &View, coll: &Collection, v: &Va
value_cell(app, ui, view, v, coll, &m.id, cell);
}
if editable {
if resp.clicked() {
let m = ui.input(|i| i.modifiers);
select_clicked(st, &v.id, m);
}
if !inherited && resp.double_clicked() && ui.input(|i| i.pointer.interact_pos()).is_some_and(|p| p.x < name_r.max.x) {
start_rename(st, target.clone());
}
let bulk = bulk_ids(view, st, v);
let coll_groups = groups(view.in_collection(&coll.id).map(|x| x.name.as_str()));
crate::right::context_popup(&resp).show(|ui| {
if let Some(vars) = &bulk {
bulk_menu(app, ui, &coll_groups, vars);
return;
}
if menu_item(ui, tr("Edit variable"), "") {
st.details = Some(v.id.clone());
ui.close();
+2
View File
@@ -257,6 +257,8 @@ mod variables_export_ui_tests;
#[cfg(test)]
mod variables_rename_tests;
#[cfg(test)]
mod variables_select_tests;
#[cfg(test)]
mod variants_discovery_tests;
#[cfg(test)]
mod vector_keys_tests;
@@ -0,0 +1,194 @@
//! Selecting several variables in the Local variables window (#2002): a click selects one row,
//! Shift+click the range from the anchor, Ctrl/Cmd+click toggles a row, Escape and a click on the
//! empty space clear; delete, move to a group and scope then act on the whole selection in one
//! undo step.
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};
const NAMES: [&str; 5] = ["alpha", "bravo", "charlie", "delta", "echo"];
/// The window open on a collection of five number variables.
fn window() -> Ui {
let mut s = Session::new();
s.execute("variable.createCollection", &json!({"name": "Theme"})).unwrap();
for n in NAMES {
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());
for _ in 0..10 {
u.frame(vec![]);
}
u
}
fn row(u: &mut Ui, name: &str) -> Pos2 {
let shapes = flat(&u.frame_output(vec![]).shapes);
// The name column, left of the value cells.
let p = text_center(&shapes, name);
Pos2::new(p.x, p.y)
}
fn click(u: &mut Ui, p: Pos2, button: PointerButton, m: Modifiers) {
u.frame_with(vec![Event::PointerMoved(p)], m);
for pressed in [true, false] {
u.frame_with(vec![Event::PointerButton { pos: p, button, pressed, modifiers: m }], m);
}
for _ in 0..5 {
u.frame(vec![]);
}
}
fn click_row(u: &mut Ui, name: &str, m: Modifiers) {
let p = row(u, name);
click(u, p, PointerButton::Primary, m);
}
fn selected(u: &Ui) -> Vec<String> {
let st = u.app.ui.variables.as_ref().unwrap();
let doc = u.app.session.doc().unwrap();
let mut names: Vec<String> = st.selected.iter().filter_map(|id| doc.variables.get_by_id(id)).map(|v| v.name.clone()).collect();
names.sort();
names
}
fn names(u: &Ui) -> Vec<String> {
u.app.session.doc().unwrap().variables.variables.iter().map(|v| v.name.clone()).collect()
}
const SHIFT: Modifiers = Modifiers { shift: true, ..Modifiers::NONE };
const CTRL: Modifiers = Modifiers { ctrl: true, command: true, ..Modifiers::NONE };
#[test]
fn a_click_selects_one_variable_and_replaces_the_selection() {
let mut u = window();
click_row(&mut u, "bravo", Modifiers::NONE);
assert_eq!(selected(&u), ["bravo"]);
click_row(&mut u, "delta", Modifiers::NONE);
assert_eq!(selected(&u), ["delta"]);
}
#[test]
fn shift_click_selects_the_range_from_the_anchor() {
let mut u = window();
click_row(&mut u, "bravo", Modifiers::NONE);
click_row(&mut u, "delta", SHIFT);
assert_eq!(selected(&u), ["bravo", "charlie", "delta"]);
// A range upward from the same anchor.
click_row(&mut u, "alpha", SHIFT);
assert_eq!(selected(&u), ["alpha", "bravo"]);
}
#[test]
fn ctrl_click_toggles_one_variable() {
let mut u = window();
click_row(&mut u, "alpha", Modifiers::NONE);
click_row(&mut u, "charlie", CTRL);
assert_eq!(selected(&u), ["alpha", "charlie"]);
click_row(&mut u, "alpha", CTRL);
assert_eq!(selected(&u), ["charlie"]);
}
#[test]
fn escape_clears_the_selection() {
let mut u = window();
click_row(&mut u, "alpha", Modifiers::NONE);
click_row(&mut u, "bravo", SHIFT);
assert_eq!(selected(&u).len(), 2);
for pressed in [true, false] {
u.frame(vec![Event::Key { key: Key::Escape, physical_key: None, pressed, repeat: false, modifiers: Modifiers::NONE }]);
}
assert!(selected(&u).is_empty());
}
#[test]
fn selected_rows_are_painted_with_the_selected_row_colour() {
let mut u = window();
let colour = crate::theme::Tokens::get(&u.ctx).selected_row;
let count = |u: &mut Ui| flat(&u.frame_output(vec![]).shapes).iter().filter(|s| matches!(s, egui::Shape::Rect(r) if r.fill == colour)).count();
let none = count(&mut u);
click_row(&mut u, "alpha", Modifiers::NONE);
let one = count(&mut u);
click_row(&mut u, "charlie", SHIFT);
let three = count(&mut u);
assert!(one > none, "the selected row is highlighted");
assert_eq!(three - one, 2, "two more rows highlighted by the range");
}
/// Select bravo..delta, then right-click delta.
fn select_three_and_open_menu(u: &mut Ui) -> Vec<egui::Shape> {
click_row(u, "bravo", Modifiers::NONE);
click_row(u, "delta", SHIFT);
assert_eq!(selected(u), ["bravo", "charlie", "delta"]);
let p = row(u, "delta");
click(u, p, PointerButton::Secondary, Modifiers::NONE);
flat(&u.frame_output(vec![]).shapes)
}
#[test]
fn bulk_delete_removes_exactly_the_selected_variables_in_one_undo_step() {
let mut u = window();
let menu = select_three_and_open_menu(&mut u);
assert!(has_text(&menu, "Delete 3 variables"));
let before = u.app.session.undo_labels(100).len();
click(&mut u, text_center(&menu, "Delete 3 variables"), PointerButton::Primary, Modifiers::NONE);
assert!(u.app.ui.last_error.is_none(), "{:?}", u.app.ui.last_error);
assert_eq!(names(&u), ["alpha", "echo"]);
assert_eq!(u.app.session.undo_labels(100).len(), before + 1, "one undo step");
u.app.session.undo().unwrap();
assert_eq!(names(&u), NAMES);
}
#[test]
fn bulk_move_to_a_group_renames_every_selected_variable_in_one_step() {
let mut u = window();
u.app.session.execute("variable.create", &json!({"collection": "Theme", "name": "space/zero", "type": "number", "value": 0})).unwrap();
let menu = select_three_and_open_menu(&mut u);
let before = u.app.session.undo_labels(100).len();
click(&mut u, text_center(&menu, "Move to group space"), PointerButton::Primary, Modifiers::NONE);
assert!(u.app.ui.last_error.is_none(), "{:?}", u.app.ui.last_error);
let mut now = names(&u);
now.sort();
assert_eq!(now, ["alpha", "echo", "space/bravo", "space/charlie", "space/delta", "space/zero"]);
assert_eq!(u.app.session.undo_labels(100).len(), before + 1, "one undo step");
u.app.session.undo().unwrap();
assert!(names(&u).contains(&"bravo".to_string()) && names(&u).contains(&"delta".to_string()));
}
#[test]
fn bulk_scope_change_reaches_every_selected_variable_in_one_step() {
let mut u = window();
let menu = select_three_and_open_menu(&mut u);
let before = u.app.session.undo_labels(100).len();
click(&mut u, text_center(&menu, "Scope: only Corner radius"), PointerButton::Primary, Modifiers::NONE);
assert!(u.app.ui.last_error.is_none(), "{:?}", u.app.ui.last_error);
let scoped: Vec<String> = u
.app
.session
.doc()
.unwrap()
.variables
.variables
.iter()
.filter(|v| v.scopes.as_deref() == Some(&["CORNER_RADIUS".to_string()][..]))
.map(|v| v.name.clone())
.collect();
assert_eq!(scoped, ["bravo", "charlie", "delta"]);
assert_eq!(u.app.session.undo_labels(100).len(), before + 1, "one undo step");
}
#[test]
fn a_row_outside_the_selection_keeps_the_single_variable_menu() {
let mut u = window();
click_row(&mut u, "alpha", Modifiers::NONE);
click_row(&mut u, "bravo", SHIFT);
let p = row(&mut u, "echo");
click(&mut u, p, PointerButton::Secondary, Modifiers::NONE);
let menu = flat(&u.frame_output(vec![]).shapes);
assert!(has_text(&menu, "Delete variable") && !has_text(&menu, "Delete 2 variables"));
}
+3 -2
View File
@@ -1,6 +1,6 @@
# Components, variants, styles and variables parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-01 · **Change:** minor (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-05 · **Change:** minor (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 all of them in one undo step (#2002); 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
@@ -63,7 +63,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, size, line height and letter spacing, the rest through the command |
| 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 |
| 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 |
| 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 |
@@ -78,6 +78,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
| Date | Change | Summary |
|---|---|---|
| 2026-11-05 | minor | M3, #2002: the Local variables window selects several variables, as the Layers panel selects layers. A click selects one row, Shift+click the range from the anchor through the rows shown, Cmd/Ctrl+click toggles a row, Escape or a click on the empty space below the rows clears; selected rows use the sidebar's selected-row colour. Right-clicking a row that is part of a selection of several offers Delete, Move to group and Scope (all supported properties, hidden from pickers, or only one scope) for the whole selection, each sent as one `command.batch`, so one undo step; no engine command changed. Renaming and value edits stay single-row. Tests: `variables_select_tests` (headless UI). Grade unchanged |
| 2026-11-01 | patch | M3: Delete on a layer inside an instance hides it (an override) instead of being refused ("You can't delete a layer or object from an instance. If you try, Figma will only toggle the layer's visibility instead of removing it", Guide to auto layout); `edit.delete` reports those ids under `hidden`, the structure and the main component stay as they were, one undo step; deleting the instance itself still removes it. Found by a documentation audit of the auto layout page. Test: `components_behaviour_tests::deleting_a_layer_inside_an_instance_hides_it_instead` (the refusal row for it is gone from `what_instances_cannot_override_is_refused`). Numbers unchanged |
| 2026-10-31 | minor | M3, gap 10: library analytics cover styles and variables. A file reports how many of its layers use each of a library's styles and variables, and Show usage (`library.usage`) lists them beside the components, by a Type choice, with their layers and files. Layers inside instances count for their component. Insertions, detachments and modes aren't counted for them yet. Numbers unchanged. Tests: `library_assets_tests`. |
| 2026-10-31 | minor | M6: as the help center describes code syntax, Dev Mode's SwiftUI and Compose code now writes a bound variable's iOS or Android code syntax in place of its value, as CSS already wrote the Web one: fills, strokes and their weight, sizes, corner radius, gaps, padding, opacity, the font family and size and the characters. A variable with no code syntax for the platform keeps the value, since a name made up here wouldn't exist in the code it lands in. ArkUI and Flutter have no code syntax platform and are unchanged. Test: `variables_behaviour_tests::swiftui_and_compose_name_variables_by_their_code_syntax`. Numbers unchanged. Grade unchanged |