AI-native design editor. Open-source Figma alternative.
feat(app): share the variable picker between the panel and the variables dialog (#994)
Danila Poyarkovf3ffc0664082
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e4ec32b62..1ad1c11bb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -89,6 +89,7 @@### Changed+- The properties panel's variable picker groups variables by collection and shows each color variable's swatch, and the variables dialog points a value at another variable with the same picker, detaching it from the picker's footer.- **Add variant** on a component set copies its last variant below it, 20 px apart, with the next free value such as `Variant3`, and grows the set to hold it, as Figma does. It used to place a copy with the same values to the right, which made a duplicate combination.- The `get_selection` tool returns the selected layers with their direct children by default instead of their whole subtrees, and takes a `depth` for more or fewer levels, so agents can start from what the user selected without reading the full tree.- The width and height menus in the properties panel offer Hug only for auto-layout frames and text, as in Figma; on a frame without auto layout it had no effect.diff --git a/packages/vue/src/controls/binding-provider/open-pencil.ts b/packages/vue/src/controls/binding-provider/open-pencil.tsindex f7fbbc614..8d7d179af 100644--- a/packages/vue/src/controls/binding-provider/open-pencil.ts+++ b/packages/vue/src/controls/binding-provider/open-pencil.ts@@ -86,6 +86,7 @@ export function createOpenPencilBindingProvider<V>(return {revision,listVariables: variables,+ collectionName: (variable) => editor.getCollection(variable.collectionId)?.name,filterVariables,getBindingId: (target) => editor.getNode(target.nodeId)?.boundVariables[target.path],getBound,diff --git a/packages/vue/src/controls/binding-provider/types.ts b/packages/vue/src/controls/binding-provider/types.tsindex 50ef0f523..c60516c97 100644--- a/packages/vue/src/controls/binding-provider/types.ts+++ b/packages/vue/src/controls/binding-provider/types.ts@@ -23,6 +23,8 @@ export interface BindingProvider<V = unknown> {/** Optional reactive revision consumed by BindableValueRoot. */revision?: Readonly<Ref<unknown>>listVariables(): Variable[]+ /** The name of the collection a variable belongs to, which pickers group variables by. */+ collectionName?(variable: Variable): string | undefinedfilterVariables(term: string): Variable[]getBindingId(target: BindingTarget): string | undefinedgetBound(target: BindingTarget): Variable | undefineddiff --git a/src/components/properties/binding/VariableBindingPicker.vue b/src/components/properties/binding/VariableBindingPicker.vueindex 1cdd2434a..789d308fa 100644--- a/src/components/properties/binding/VariableBindingPicker.vue+++ b/src/components/properties/binding/VariableBindingPicker.vue@@ -18,14 +18,14 @@ export interface VariableBindingPickerProps {</script><script setup lang="ts">-import { computed, nextTick, ref, watch } from 'vue'+import { computed } from 'vue'-import { useBindableValue, useI18n } from '@open-pencil/vue'+import type { Color } from '@open-pencil/scene-graph/primitives'+import { useBindableValue } from '@open-pencil/vue'-import { BindingTrigger, useBindingFieldUI } from '@/components/ui/binding'-import AppButton from '@/components/ui/button/AppButton.vue'-import AppPicker, { type AppPickerItem } from '@/components/ui/select/AppPicker.vue'+import { VariablePicker, type VariablePickerItem } from '@/components/ui/binding'+/** The variable picker of a field inside `BindableValueRoot`, binding the field's targets. */const {triggerLabel,searchPlaceholder,@@ -33,139 +33,60 @@ const {detachLabel,closeLabel,createLabel,- createNamePlaceholder = 'Variable name',- createSubmitLabel = 'Create',- createDefaultName = '',- disabled = false,- derived = false,+ createNamePlaceholder,+ createSubmitLabel,+ createDefaultName,+ disabled,+ derived,ui} = defineProps<VariableBindingPickerProps>()const binding = useBindableValue<unknown>()-const { common } = useI18n()-const creating = ref(false)-const createName = ref('')-const createInput = ref<HTMLInputElement | null>(null)-const canCreate = computed(() => createName.value.trim().length > 0)-const styles = computed(() =>- useBindingFieldUI(- {- state: binding.state.value,- open: binding.open.value,- disabled,- derived- },- ui- )-)const open = computed({get: () => binding.open.value,set: (value: boolean) => (value ? binding.actions.openPicker() : binding.actions.closePicker())})-const items = computed<AppPickerItem[]>(() =>- binding.variables.value.map((variable) => ({ value: variable.id, label: variable.name }))-)--function startCreate() {- creating.value = true- createName.value = createDefaultName- void nextTick(() => {- createInput.value?.focus()- createInput.value?.select()- })-}-function submitCreate() {- const name = createName.value.trim()- if (!name) return- binding.actions.create(name)+function isColor(value: unknown): value is Color {+ return typeof value === 'object' && value !== null && 'r' in value}-function detach() {- binding.actions.unbind()- binding.actions.closePicker()-}--watch(binding.open, (isOpen) => {- if (!isOpen) creating.value = false-})+const items = computed<VariablePickerItem[]>(() =>+ binding.variables.value.map((variable) => {+ const value = variable.type === 'COLOR' ? binding.provider.resolve(variable.id) : undefined+ return {+ id: variable.id,+ name: variable.name,+ collection: binding.provider.collectionName?.(variable),+ color: isColor(value) ? value : undefined+ }+ })+)defineOptions({ inheritAttrs: false })</script><template>- <span class="inline-flex shrink-0 items-center" data-slot="anchor">- <AppPicker- v-model:open="open"- :heading="triggerLabel"- :items="items"- :selected="binding.variable.value?.id"- density="compact"- :search-placeholder="searchPlaceholder"- :empty-label="emptyLabel"- :close-label="closeLabel ?? common.close"- :tooltip="triggerLabel"- @select="binding.actions.bind($event)"- >- <template #trigger>- <BindingTrigger- :label="triggerLabel"- :state="binding.state.value"- :open="binding.open.value"- :disabled="disabled"- :derived="derived"- :ui="ui"- />- </template>- <template #leading>- <icon-lucide-diamond class="size-3.5 text-component" />- </template>- <template #footer>- <AppButton- v-if="binding.state.value !== 'unbound'"- size="xs"- class="w-full justify-start"- data-slot="action"- @click="detach"- >- <template #leading><icon-lucide-unlink class="size-3" /></template>- {{ detachLabel }}- </AppButton>- <form- v-if="creating"- :class="styles.createForm"- data-slot="createForm"- @submit.prevent="submitCreate"- @keydown.esc.prevent.stop="creating = false"- >- <input- ref="createInput"- v-model="createName"- :placeholder="createNamePlaceholder"- :class="styles.createInput"- data-slot="createInput"- />- <AppButton- size="xs"- variant="soft"- :disabled="!canCreate"- data-slot="createSubmit"- type="submit"- >- {{ createSubmitLabel }}- </AppButton>- </form>- <AppButton- v-else-if="createLabel"- size="xs"- class="w-full justify-start"- data-slot="action"- @click="startCreate"- >- <template #leading><icon-lucide-plus class="size-3" /></template>- <span class="min-w-0 flex-1 truncate text-left">{{ createLabel }}</span>- </AppButton>- </template>- </AppPicker>- </span>+ <VariablePicker+ v-bind="$attrs"+ :trigger-label="triggerLabel"+ :search-placeholder="searchPlaceholder"+ :empty-label="emptyLabel"+ :detach-label="detachLabel"+ :close-label="closeLabel"+ :create-label="createLabel"+ :create-name-placeholder="createNamePlaceholder"+ :create-submit-label="createSubmitLabel"+ :create-default-name="createDefaultName"+ :disabled="disabled"+ :derived="derived"+ :ui="ui"+ v-model:open="open"+ :items="items"+ :selected="binding.variable.value?.id"+ :state="binding.state.value"+ @select="binding.actions.bind($event)"+ @detach="binding.actions.unbind()"+ @create="binding.actions.create($event)"+ /></template>diff --git a/src/components/ui/binding/VariablePicker.vue b/src/components/ui/binding/VariablePicker.vuenew file mode 100644index 000000000..c9b5dc835--- /dev/null+++ b/src/components/ui/binding/VariablePicker.vue@@ -0,0 +1,166 @@+<script setup lang="ts">+import { computed, nextTick, ref, watch } from 'vue'++import { useI18n } from '@open-pencil/vue'++import AppButton from '@/components/ui/button/AppButton.vue'+import FillSwatch from '@/components/ui/paint/FillSwatch.vue'+import AppPicker, { type AppPickerItem } from '@/components/ui/select/AppPicker.vue'++import BindingTrigger from './BindingTrigger.vue'+import type { VariablePickerProps } from './picker'+import { useBindingFieldUI } from './ui'++/**+ * Picks the variable a value points at: the Properties panel binds a layer's field with it and+ * the Variables dialog aliases a mode's value, so both look and work the same.+ */+const {+ items,+ selected,+ state,+ triggerLabel,+ searchPlaceholder,+ emptyLabel,+ detachLabel,+ closeLabel,+ createLabel,+ createNamePlaceholder = 'Variable name',+ createSubmitLabel = 'Create',+ createDefaultName = '',+ disabled = false,+ derived = false,+ side,+ ui+} = defineProps<VariablePickerProps>()+const open = defineModel<boolean>('open', { default: false })+const emit = defineEmits<{ select: [id: string]; detach: []; create: [name: string] }>()++const { common } = useI18n()+const creating = ref(false)+const createName = ref('')+const createInput = ref<HTMLInputElement | null>(null)+const canCreate = computed(() => createName.value.trim().length > 0)+const styles = computed(() => useBindingFieldUI({ state, open: open.value, disabled, derived }, ui))+const pickerItems = computed<AppPickerItem[]>(() =>+ items.map((item) => ({ value: item.id, label: item.name, group: item.collection }))+)++function color(id: string) {+ return items.find((item) => item.id === id)?.color+}++function startCreate() {+ creating.value = true+ createName.value = createDefaultName+ void nextTick(() => {+ createInput.value?.focus()+ createInput.value?.select()+ })+}++function submitCreate() {+ const name = createName.value.trim()+ if (name) emit('create', name)+}++function detach() {+ emit('detach')+ open.value = false+}++watch(open, (isOpen) => {+ if (!isOpen) creating.value = false+})++defineOptions({ inheritAttrs: false })+</script>++<template>+ <span class="inline-flex shrink-0 items-center" data-slot="anchor">+ <AppPicker+ v-model:open="open"+ :heading="triggerLabel"+ :items="pickerItems"+ :selected="selected"+ density="compact"+ :search-placeholder="searchPlaceholder"+ :empty-label="emptyLabel"+ :close-label="closeLabel ?? common.close"+ :tooltip="triggerLabel"+ :side="side"+ @select="emit('select', $event)"+ >+ <template #trigger>+ <BindingTrigger+ v-bind="$attrs"+ :label="triggerLabel"+ :state="state"+ :open="open"+ :disabled="disabled"+ :derived="derived"+ :ui="ui"+ />+ </template>+ <template #leading="{ item }">+ <FillSwatch+ v-if="color(item.value)"+ :fill="{+ type: 'SOLID',+ visible: true,+ opacity: color(item.value)?.a ?? 1,+ color: color(item.value) ?? { r: 0, g: 0, b: 0, a: 1 }+ }"+ :ui="{ root: 'size-3.5 shrink-0 rounded-sm' }"+ />+ <icon-lucide-diamond v-else class="size-3.5 text-component" />+ </template>+ <template #footer>+ <AppButton+ v-if="state !== 'unbound'"+ size="xs"+ class="w-full justify-start"+ data-slot="action"+ @click="detach"+ >+ <template #leading><icon-lucide-unlink class="size-3" /></template>+ {{ detachLabel }}+ </AppButton>+ <form+ v-if="creating"+ :class="styles.createForm"+ data-slot="createForm"+ @submit.prevent="submitCreate"+ @keydown.esc.prevent.stop="creating = false"+ >+ <input+ ref="createInput"+ v-model="createName"+ :placeholder="createNamePlaceholder"+ :class="styles.createInput"+ data-slot="createInput"+ />+ <AppButton+ size="xs"+ variant="soft"+ :disabled="!canCreate"+ data-slot="createSubmit"+ type="submit"+ >+ {{ createSubmitLabel }}+ </AppButton>+ </form>+ <AppButton+ v-else-if="createLabel"+ size="xs"+ class="w-full justify-start"+ data-slot="action"+ @click="startCreate"+ >+ <template #leading><icon-lucide-plus class="size-3" /></template>+ <span class="min-w-0 flex-1 truncate text-left">{{ createLabel }}</span>+ </AppButton>+ </template>+ </AppPicker>+ </span>+</template>diff --git a/src/components/ui/binding/index.ts b/src/components/ui/binding/index.tsindex 336967964..cd9ccfd9e 100644--- a/src/components/ui/binding/index.ts+++ b/src/components/ui/binding/index.ts@@ -2,3 +2,5 @@ export { default as BindingPill } from './BindingPill.vue'export { default as BindingTrigger } from './BindingTrigger.vue'export { useBindingFieldUI } from './ui'export type { BindingFieldUI, BindingFieldUIOptions } from './ui'+export { default as VariablePicker } from './VariablePicker.vue'+export type { VariablePickerItem, VariablePickerProps } from './picker'diff --git a/src/components/ui/binding/picker.ts b/src/components/ui/binding/picker.tsnew file mode 100644index 000000000..ffbdd13df--- /dev/null+++ b/src/components/ui/binding/picker.ts@@ -0,0 +1,33 @@+import type { Color } from '@open-pencil/scene-graph/primitives'+import type { BindingState } from '@open-pencil/vue'++import type { BindingFieldUI } from './ui'++export interface VariablePickerItem {+ id: string+ name: string+ /** The collection the variable belongs to; the list groups by it. */+ collection?: string+ /** A color variable's value, shown as a swatch in place of the variable icon. */+ color?: Color+}++export interface VariablePickerProps {+ items: VariablePickerItem[]+ /** The variable the value points at now, checked in the list. */+ selected?: string+ state: BindingState+ triggerLabel: string+ searchPlaceholder: string+ emptyLabel: string+ detachLabel: string+ closeLabel?: string+ createLabel?: string+ createNamePlaceholder?: string+ createSubmitLabel?: string+ createDefaultName?: string+ disabled?: boolean+ derived?: boolean+ side?: 'left' | 'right' | 'top' | 'bottom'+ ui?: BindingFieldUI+}diff --git a/src/components/ui/select/AppPicker.vue b/src/components/ui/select/AppPicker.vueindex b44a426b4..abed9c85f 100644--- a/src/components/ui/select/AppPicker.vue+++ b/src/components/ui/select/AppPicker.vue@@ -77,7 +77,7 @@ import { computed, shallowRef, useTemplateRef, watch, type ComponentPublicInstanimport { fuzzySearch, useRetainedPopup } from '@open-pencil/vue'-import AppButton from '@/components/ui/button/AppButton.vue'+import IconButton from '@/components/ui/button/IconButton.vue'import Tip from '@/components/ui/overlay/Tip.vue'import theme, { APP_PICKER_GRID_COLUMNS } from '@/theme/select/picker'@@ -196,9 +196,9 @@ function select(value: AcceptableValue) {<div :class="styles.header({ class: ui?.header })"><h3 :class="styles.title({ class: ui?.title })">{{ heading }}</h3><PopoverClose as-child>- <AppButton :aria-label="closeLabel" class="ml-auto">+ <IconButton :label="closeLabel"><icon-lucide-x class="size-3.5" />- </AppButton>+ </IconButton></PopoverClose></div><ListboxRootdiff --git a/src/components/variables/TokenAliasPicker.vue b/src/components/variables/TokenAliasPicker.vuedeleted file mode 100644index d0cae515c..000000000--- a/src/components/variables/TokenAliasPicker.vue+++ /dev/null@@ -1,68 +0,0 @@-<script setup lang="ts">-import { computed, ref } from 'vue'--import { useI18n } from '@open-pencil/vue'--import type { AliasCandidate } from '@/app/editor/tokens/model'-import IconButton from '@/components/ui/button/IconButton.vue'-import FillSwatch from '@/components/ui/paint/FillSwatch.vue'-import AppPicker, { type AppPickerItem } from '@/components/ui/select/AppPicker.vue'--/** Points a mode's value at another variable, the way Figma's variable picker does. */-const { candidates, selected, label } = defineProps<{- candidates: AliasCandidate[]- /** The variable the value points at now, checked in the list. */- selected?: string- /** The trigger's accessible name, naming the mode it sets. */- label: string-}>()-const emit = defineEmits<{ select: [variableId: string] }>()--const { variables, common } = useI18n()-const open = ref(false)--const items = computed<AppPickerItem[]>(() =>- candidates.map((candidate) => ({- value: candidate.id,- label: candidate.name,- group: candidate.collection- }))-)--function color(id: string) {- return candidates.find((candidate) => candidate.id === id)?.color-}-</script>--<template>- <AppPicker- v-model:open="open"- :heading="variables.useVariable"- :items="items"- :selected="selected"- :search-placeholder="variables.searchVariables"- :empty-label="variables.noMatchingVariables"- :close-label="common.close"- density="compact"- side="left"- @select="emit('select', $event)"- >- <template #trigger>- <IconButton :label="label" data-test-id="variables-use-variable">- <icon-lucide-variable class="size-3.5" />- </IconButton>- </template>- <template #leading="{ item }">- <FillSwatch- v-if="color(item.value)"- :fill="{- type: 'SOLID',- visible: true,- opacity: color(item.value)?.a ?? 1,- color: color(item.value) ?? { r: 0, g: 0, b: 0, a: 1 }- }"- :ui="{ root: 'size-3.5 shrink-0 rounded-sm' }"- />- </template>- </AppPicker>-</template>diff --git a/src/components/variables/TokenInspector.vue b/src/components/variables/TokenInspector.vueindex d1335f575..ccf710eec 100644--- a/src/components/variables/TokenInspector.vue+++ b/src/components/variables/TokenInspector.vue@@ -29,14 +29,13 @@ import { useI18n } from '@open-pencil/vue'import type { AliasCandidate, TokenRow } from '@/app/editor/tokens/model'import { SCOPES_BY_TYPE } from '@/app/editor/tokens/scopes'import ColorInput from '@/components/ColorPicker/ColorInput.vue'-import BindingPill from '@/components/ui/binding/BindingPill.vue'+import { BindingPill, VariablePicker } from '@/components/ui/binding'import AppButton from '@/components/ui/button/AppButton.vue'-import IconButton from '@/components/ui/button/IconButton.vue'import AppInput from '@/components/ui/input/AppInput.vue'import AppTextarea from '@/components/ui/input/AppTextarea.vue'+import FillSwatch from '@/components/ui/paint/FillSwatch.vue'import AppSelect from '@/components/ui/select/AppSelect.vue'import AppCheckbox from '@/components/ui/toggle/AppCheckbox.vue'-import TokenAliasPicker from '@/components/variables/TokenAliasPicker.vue'import tokensPanelTheme from '@/theme/tokens-panel'const {@@ -224,6 +223,11 @@ function alias(modeId: string) {return row.values.find((value) => value.modeId === modeId)?.alias}+/** The color an aliased value resolves to, shown beside the variable as the panel does. */+function aliasColor(modeId: string): Color | undefined {+ return row.values.find((value) => value.modeId === modeId)?.color+}+function aliasId(modeId: string): string | undefined {const value = variable.value.valuesByMode[modeId]return typeof value === 'object' && 'aliasId' in value ? value.aliasId : undefined@@ -305,14 +309,17 @@ function cssNameDone(event: KeyboardEvent) {<span v-if="!singleMode" :class="ui.label()">{{ mode.name }}</span><div :class="ui.valueRow()"><div v-if="alias(mode.modeId)" :class="ui.valueControl()">- <BindingPill :label="alias(mode.modeId) ?? ''" />- <IconButton- :label="variables.detachVariable"- data-test-id="variables-detach-variable"- @click="emit('detach', mode.modeId)"- >- <icon-lucide-unlink class="size-3.5" />- </IconButton>+ <FillSwatch+ v-if="aliasColor(mode.modeId)"+ :fill="{+ type: 'SOLID',+ visible: true,+ opacity: aliasColor(mode.modeId)?.a ?? 1,+ color: aliasColor(mode.modeId) ?? { r: 0, g: 0, b: 0, a: 1 }+ }"+ :ui="{ root: 'size-5 shrink-0' }"+ />+ <BindingPill class="min-w-0 flex-1" :label="alias(mode.modeId) ?? ''" /></div><ColorInputv-else-if="color(mode.modeId)"@@ -339,11 +346,20 @@ function cssNameDone(event: KeyboardEvent) {<span :class="ui.hint()">{{ numberUnit }}</span></template></AppInput>- <TokenAliasPicker- :candidates="aliasCandidates"+ <VariablePicker+ :items="aliasCandidates":selected="aliasId(mode.modeId)"- :label="singleMode ? variables.useVariable : `${mode.name}: ${variables.useVariable}`"+ :state="aliasId(mode.modeId) ? 'bound' : 'unbound'"+ :trigger-label="+ singleMode ? variables.useVariable : `${mode.name}: ${variables.useVariable}`+ "+ :search-placeholder="variables.searchVariables"+ :empty-label="variables.noMatchingVariables"+ :detach-label="variables.detachVariable"+ side="left"+ data-test-id="variables-use-variable"@select="emit('alias', mode.modeId, $event)"+ @detach="emit('detach', mode.modeId)"/></div><AppInputdiff --git a/src/theme/select/picker.ts b/src/theme/select/picker.tsindex 0ad5afd86..7c6ece01c 100644--- a/src/theme/select/picker.ts+++ b/src/theme/select/picker.ts@@ -13,8 +13,9 @@ const appPickerTheme = {floatingSurface,motionStyles.floating],- header: 'flex items-center gap-1.5 border-b border-border px-3 py-2',- title: 'text-xs font-semibold text-surface',+ // The title and close button line up with the panel's section headers and the search field.+ header: 'flex h-9 shrink-0 items-center gap-1.5 border-b border-border pr-2 pl-3',+ title: 'min-w-0 flex-1 truncate text-[11px] font-semibold text-surface',search: [panelFieldBase, 'relative m-2 flex h-7 shrink-0 items-center'],searchIcon: 'pointer-events-none absolute left-2 size-3.5 text-muted',input:diff --git a/src/theme/tokens-panel.ts b/src/theme/tokens-panel.tsindex c206710d2..c0c8538ba 100644--- a/src/theme/tokens-panel.ts+++ b/src/theme/tokens-panel.ts@@ -64,7 +64,7 @@ export default {'w-full min-w-0 rounded border border-accent bg-input px-1.5 py-0.5 text-xs text-surface outline-none',/** A mode's value control beside the button that points it at a variable. */valueRow: 'flex items-center gap-1 [&>*:first-child]:min-w-0 [&>*:first-child]:flex-1',- valueControl: 'flex min-w-0 items-center gap-1',+ valueControl: 'flex min-w-0 items-center gap-1.5',empty: 'px-4 py-8 text-center text-xs text-muted'},variants: {diff --git a/tests/e2e/properties/unresolved-binding.spec.ts b/tests/e2e/properties/unresolved-binding.spec.tsindex 73b261790..26080fc4e 100644--- a/tests/e2e/properties/unresolved-binding.spec.ts+++ b/tests/e2e/properties/unresolved-binding.spec.ts@@ -67,6 +67,7 @@ for (const theme of ['light', 'dark']) {editor.select([id])})const section = page.getByRole('region', { name: 'Typography', exact: true })+ const picker = page.getByRole('dialog', { name: 'Apply variable' })const field = section.locator('[data-property="letterSpacing"]')await expect(field.locator('[data-slot="pill"]')).toHaveAttribute('data-unresolved')await expect(field).toContainText('Tracking/Missing alias')@@ -84,6 +85,8 @@ for (const theme of ['light', 'dark']) {await expect(paint.locator('[data-slot="pill"]')).toHaveAttribute('data-unresolved')await paint.getByRole('button', { name: 'Apply variable' }).click()await page.getByRole('option', { name: 'Paint/Replacement' }).click()+ // A closed picker stays in the page while it animates out; the next field's must be the only one.+ await expect(picker).toHaveCount(0)await expect(paint).toContainText('Paint/Replacement')await expect(paint.locator('[data-slot="pill"]')).not.toHaveAttribute('data-unresolved')}diff --git a/tests/e2e/variables/dialog.spec.ts b/tests/e2e/variables/dialog.spec.tsindex e70aafe8c..817fe515d 100644--- a/tests/e2e/variables/dialog.spec.ts+++ b/tests/e2e/variables/dialog.spec.ts@@ -220,22 +220,25 @@ test('the View menu opens the variables dialog', async () => {editor.canvas.assertNoErrors()})+/** The first mode's variable picker in the inspector. */+function useVariable() {+ return editor.page.getByTestId('token-inspector').getByTestId('variables-use-variable').first()+}+test('a value points at another variable and detaches to what it showed', async () => {await variableRows().filter({ hasText: 'SwatchVar' }).click()await expect(inspectorName()).toHaveValue('SwatchVar')- await editor.page- .getByTestId('token-inspector')- .getByTestId('variables-use-variable')- .first()- .click()+ await useVariable().click()await editor.page.getByRole('dialog', { name: 'Use a variable' }).getByRole('option', { name: /brand-color/ }).click()await expect(variableRows().filter({ hasText: 'SwatchVar' })).toContainText('brand-color')- await editor.page.getByTestId('variables-detach-variable').first().click()+ // Detach sits in the same picker, as in the Properties panel.+ await useVariable().click()+ await editor.page.getByRole('button', { name: 'Detach variable' }).click()await expect(variableRows().filter({ hasText: 'SwatchVar' })).toContainText('#FF0000')editor.canvas.assertNoErrors()})