Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(table): hold several values in a column of any type
Elian Doran2f697e29694a
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex fed3a402d3..0d4f9d999d 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1335,7 +1335,8 @@"remove_this_attribute": "Remove this attribute","remove_color": "Remove the color label","remove_value": "Remove this value",- "select_values_placeholder": "Select an option or create one"+ "select_values_placeholder": "Select an option or create one",+ "values_placeholder": "Type a value and press Enter"},"script_executor": {"query": "Query",diff --git a/apps/client/src/widgets/attribute_widgets/select_input.css b/apps/client/src/widgets/attribute_widgets/select_input.cssindex 52e0109a3d..4ae913220f 100644--- a/apps/client/src/widgets/attribute_widgets/select_input.css+++ b/apps/client/src/widgets/attribute_widgets/select_input.css@@ -7,12 +7,3 @@color: var(--muted-text-color);}}--/*- * The chips of a multi-valued select. They hold text rather than a box typed into, so they need none- * of the field styling the shared chip leaves to its contents — only room for the word itself.- */-.form-autocomplete-field .select-values-chip > span {- padding-block: 2px;- white-space: nowrap;-}diff --git a/apps/client/src/widgets/attribute_widgets/values_input.spec.tsx b/apps/client/src/widgets/attribute_widgets/values_input.spec.tsxnew file mode 100644index 0000000000..fbbd32c75e--- /dev/null+++ b/apps/client/src/widgets/attribute_widgets/values_input.spec.tsx@@ -0,0 +1,96 @@+import { render } from "preact";+import { act } from "preact/test-utils";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import ValuesInput from "./values_input";++describe("ValuesInput", () => {+ let container: HTMLElement;++ beforeEach(() => {+ container = document.createElement("div");+ document.body.appendChild(container);+ });++ afterEach(() => {+ render(null, container);+ container.remove();+ });++ async function mount(props: Parameters<typeof ValuesInput>[0]) {+ await act(async () => render(<ValuesInput {...props} />, container));+ return container.querySelector("input");+ }++ async function typeInto(input: HTMLInputElement | null, value: string) {+ await act(async () => {+ if (input) {+ input.value = value;+ input.dispatchEvent(new Event("input", { bubbles: true }));+ }+ });+ }++ async function press(input: HTMLInputElement | null, key: string) {+ await act(async () => {+ input?.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true }));+ });+ }++ it("shows the values held as chips, and drops the one pressed", async () => {+ const onCommit = vi.fn();+ await mount({ labelType: "text", values: [ "one", "two" ], onCommit });++ const chips = [ ...container.querySelectorAll(".tn-chip") ];+ expect(chips.map((chip) => chip.textContent?.trim())).toEqual([ "one", "two" ]);++ await act(async () => chips[0]?.querySelector<HTMLElement>(".tn-chip-remove")?.click());+ expect(onCommit).toHaveBeenCalledWith([ "two" ]);+ });++ it("takes what was typed on Enter and empties the box, refusing a second of the same", async () => {+ const onCommit = vi.fn();+ const input = await mount({ labelType: "text", values: [ "one" ], onCommit });++ // Surrounding space goes with the typing, not into the value.+ await typeInto(input, " two ");+ await press(input, "Enter");+ expect(onCommit).toHaveBeenCalledWith([ "one", "two" ]);+ expect(input?.value).toBe("");++ // A value already held would come out as a second chip there is no telling apart.+ onCommit.mockClear();+ await typeInto(input, "one");+ await press(input, "Enter");+ expect(onCommit).not.toHaveBeenCalled();+ expect(input?.value).toBe("");+ });++ it("takes what was typed when the field is left, rather than throwing it away", async () => {+ // What is typed here is the value itself, so leaving with something in the box would lose it+ // — and a date is picked rather than typed, with no Enter to end it.+ const onCommit = vi.fn();+ const input = await mount({ labelType: "date", values: [], onCommit });++ expect(input?.type).toBe("date");+ await typeInto(input, "2026-07-29");+ await act(async () => {+ input?.dispatchEvent(new FocusEvent("focusout", { bubbles: true }));+ });+ expect(onCommit).toHaveBeenCalledWith([ "2026-07-29" ]);+ });++ it("drops the last chip on backspace in an empty box, and leaves a filled one alone", async () => {+ const onCommit = vi.fn();+ const input = await mount({ labelType: "text", values: [ "one", "two" ], onCommit });++ await press(input, "Backspace");+ expect(onCommit).toHaveBeenCalledWith([ "one" ]);++ // With something typed, backspace is the box's own to erase with.+ onCommit.mockClear();+ await typeInto(input, "th");+ await press(input, "Backspace");+ expect(onCommit).not.toHaveBeenCalled();+ });+});diff --git a/apps/client/src/widgets/attribute_widgets/values_input.tsx b/apps/client/src/widgets/attribute_widgets/values_input.tsxnew file mode 100644index 0000000000..82c63d55fc--- /dev/null+++ b/apps/client/src/widgets/attribute_widgets/values_input.tsx@@ -0,0 +1,83 @@+import { type LabelType } from "@triliumnext/commons";+import type { TargetedKeyboardEvent } from "preact";+import { useState } from "preact/hooks";++import { t } from "../../services/i18n";+import Chip from "../react/Chip";+import FormTextBox from "../react/FormTextBox";+import { LABEL_MAPPINGS } from "./label_value_input";++interface ValuesInputProps {+ /** What kind of value is being entered, deciding the box the next one is typed into. */+ labelType: LabelType;+ /** The values held, in the order they are shown. */+ values: readonly string[];+ /** Receives the values as they now stand, whenever one is taken or dropped. */+ onCommit(values: string[]): void;+ placeholder?: string;+ disabled?: boolean;+}++/**+ * The field a free-form label holding several values is edited through: the values as chips, and a+ * box after them for the next one.+ *+ * Where a select picks from a closed set, here what is typed *is* the value — so the box hands it+ * over on Enter, and again when the field is left, so that a value typed and then abandoned is kept+ * rather than quietly dropped. A value already held is not taken a second time: the chips are a set,+ * and two alike could not be told apart.+ */+export default function ValuesInput({ labelType, values, onCommit, placeholder, disabled }: ValuesInputProps) {+ const [ draft, setDraft ] = useState("");++ function take(value: string) {+ const trimmed = value.trim();+ setDraft("");+ if (!trimmed || values.includes(trimmed)) return;+ onCommit([ ...values, trimmed ]);+ }++ function drop(value: string) {+ onCommit(values.filter((held) => held !== value));+ }++ function handleKeyDown(e: TargetedKeyboardEvent<HTMLInputElement>) {+ if (e.key === "Enter") {+ // Consumed, so that it does not also reach whatever the field sits in — a table cell+ // takes Enter as "done here", which would end the edit at the first value.+ e.preventDefault();+ e.stopPropagation();+ take(e.currentTarget.value);+ } else if (e.key === "Backspace" && !e.currentTarget.value && values.length) {+ // Backspace on an empty box drops the last chip, the box having nothing of its own to+ // erase. With something typed it is the box's own, as anywhere else.+ e.preventDefault();+ drop(values[values.length - 1]);+ }+ }++ return (+ <div className="tn-chips-field values-input">+ {values.map((value) => (+ <Chip+ key={value}+ removeButtonText={t("promoted_attributes.remove_value")}+ disabled={disabled}+ onRemove={() => drop(value)}+ >+ <span>{value}</span>+ </Chip>+ ))}+ <FormTextBox+ type={LABEL_MAPPINGS[labelType] ?? "text"}+ currentValue={draft}+ // Only while the field is empty: beside chips it would read as one of them.+ placeholder={values.length ? undefined : placeholder}+ disabled={disabled}+ onChange={setDraft}+ onBlur={take}+ onKeyDown={handleKeyDown}+ />+ </div>+ );+}diff --git a/apps/client/src/widgets/collections/table/columns.css b/apps/client/src/widgets/collections/table/columns.cssindex c218a7fdea..233f4a7598 100644--- a/apps/client/src/widgets/collections/table/columns.css+++ b/apps/client/src/widgets/collections/table/columns.css@@ -1,6 +1,6 @@-/* The chips of a multi-valued select cell, read-only here: the cell shows the set, the editor edits- it. They wrap rather than being clipped one word in, a row growing to the tallest cell in it. */-.table-select-values {+/* The chips of a multi-valued cell, read-only here: the cell shows the set, the editor edits it.+ They wrap rather than being clipped one word in, a row growing to the tallest cell in it. */+.table-values {display: flex;flex-wrap: wrap;align-items: center;@@ -20,7 +20,7 @@* The cell it belongs to therefore stops clipping while it is being edited, and comes forward so the* editor is drawn over the rows below rather than under them.*/-.tabulator-row:not(.tabulator-moving) .tabulator-cell.tabulator-editing:has(> .table-select-editor) {+.tabulator-row:not(.tabulator-moving) .tabulator-cell.tabulator-editing:has(> .table-values-editor) {overflow: visible !important;z-index: 10;@@ -32,7 +32,7 @@background: transparent;}-.table-select-editor {+.table-values-editor {position: absolute;inset-block-start: 0;inset-inline-start: 0;@@ -60,14 +60,14 @@/* Over that surface the film reads as it does anywhere else: as a field within the thing itfloats on, rather than as a hole in it. */- > .form-autocomplete-field {+ > .tn-chips-field {background-color: var(--input-background-color);}}/* Anchored by its foot instead, so that what it gains rises over the rows above rather than pressingpast the foot of the pane. Applied from the editor, which is what can tell the room is short. */-.table-select-editor.grows-upwards {+.table-values-editor.grows-upwards {inset-block-start: auto;inset-block-end: 0;}diff --git a/apps/client/src/widgets/collections/table/columns.spec.ts b/apps/client/src/widgets/collections/table/columns.spec.tsindex 6a61965e67..2b99056b2c 100644--- a/apps/client/src/widgets/collections/table/columns.spec.ts+++ b/apps/client/src/widgets/collections/table/columns.spec.ts@@ -1,6 +1,6 @@import { act } from "preact/test-utils";import { describe, expect, it, vi } from "vitest";-import { buildColumnDefinitions, formatLabelDate, restoreExistingData, type SelectEditorParams } from "./columns";+import { type AttributeDefinitionInformation, buildColumnDefinitions, formatLabelDate, restoreExistingData, type ValuesEditorParams } from "./columns";import type { CellComponent, ColumnDefinition } from "tabulator-tables";import options from "../../../services/options";@@ -242,7 +242,7 @@ describe("buildColumnDefinitions — select columns", () => {function editorParamsOf(column: ColumnDefinition | undefined) {const params = column?.editorParams;if (typeof params !== "function") throw new Error("expected the params to be a function");- return params({} as CellComponent) as SelectEditorParams;+ return params({} as CellComponent) as ValuesEditorParams;}function selectColumn(@@ -291,6 +291,42 @@ describe("buildColumnDefinitions — select columns", () => {});});+describe("buildColumnDefinitions — multi-valued columns", () => {+ function multiColumn(type: AttributeDefinitionInformation["type"]) {+ return buildColumnDefinitions({+ info: [ { name: "tags", type, isMulti: true } ],+ movableRows: false,+ existingColumnData: undefined,+ rowNumberHint: 1+ }).find((column) => column.field === "labels.tags");+ }++ it("edits and shows a set as chips whatever it holds, not only a set of options", () => {+ for (const type of [ "text", "date", "url", "select" ] as const) {+ const column = multiColumn(type);+ // The type's own single-value editor would show one of the values and store back one.+ expect(typeof column?.editor).toBe("function");+ expect(typeof column?.formatter).toBe("function");+ expect(column?.formatterParams).toEqual({ type });+ // The editor is told which kind of value it is gathering, since that decides the field.+ const params = column?.editorParams;+ if (typeof params !== "function") throw new Error("expected the params to be a function");+ expect((params({} as CellComponent) as ValuesEditorParams).labelType).toBe(type);+ }+ });++ it("sorts by the values a cell holds, not by the array they arrive in", () => {+ const sorter = multiColumn("text")?.sorter;+ if (typeof sorter !== "function") throw new Error("expected a sorter of its own");++ const compare = (a: unknown, b: unknown) =>+ Math.sign((sorter as (a: unknown, b: unknown, ...rest: never[]) => number)(a, b));+ expect(compare([ "alpha", "beta" ], [ "alpha", "gamma" ])).toBe(-1);+ expect(compare([ "beta" ], [ "alpha", "beta" ])).toBe(1);+ expect(compare([ "alpha" ], [ "alpha" ])).toBe(0);+ });+});+describe("formatLabelDate", () => {it("renders dates and datetimes in the configured formatting locale", () => {options.set("formattingLocale", "de");diff --git a/apps/client/src/widgets/collections/table/columns.tsx b/apps/client/src/widgets/collections/table/columns.tsxindex b2f41914fb..e5c78238af 100644--- a/apps/client/src/widgets/collections/table/columns.tsx+++ b/apps/client/src/widgets/collections/table/columns.tsx@@ -11,6 +11,7 @@ import { t } from "../../../services/i18n.js";import { formatDateNumeric } from "../../../utils/formatters.js";import LabelValueInput from "../../attribute_widgets/label_value_input.jsx";import { SelectValuesInput } from "../../attribute_widgets/select_input.jsx";+import ValuesInput from "../../attribute_widgets/values_input.jsx";import Icon from "../../react/Icon.jsx";import NoteAutocomplete from "../../react/NoteAutocomplete.jsx";import { renderReactWidget } from "../../react/react_utils.jsx";@@ -24,7 +25,7 @@ export interface AttributeDefinitionInformation {type?: ColumnType;/** The values a `select` column offers, from the definition that declared it. */options?: string[];- /** Whether the column holds a set of values rather than one, which only a `select` may. */+ /** Whether the column holds a set of values rather than one, shown and edited as chips. */isMulti?: boolean;}@@ -189,22 +190,25 @@ export function buildColumnDefinitions({ info, movableRows, existingColumnData,editor: "input",rowHandle: false,...labelTypeMappings[type ?? "text"],- // A select's options come from its own definition, so they attach per column. Handed as- // a function because that is the shape Tabulator types for params of an editor's own —- // which also means the options are answered for as each cell is opened, late enough to- // include one the definition has just been given.- ...(type === "select" && {+ // What a cell's editor needs beyond the value itself, which for a select is the options+ // it offers. Handed as a function because that is the shape Tabulator types for params+ // of an editor's own — which also means the options are answered for as each cell is+ // opened, late enough to include one the definition has just been given.+ ...((type === "select" || isMulti) && {editorParams: (): Record<string, unknown> => ({+ labelType: type ?? "text",options: currentSelectOptions?.(name) ?? options ?? [],isMulti,onCreateOption: onCreateSelectOption&& ((option: string) => onCreateSelectOption(name, option))- } satisfies SelectEditorParams)+ } satisfies ValuesEditorParams)}),- // A set is shown as the chips it is edited as, and sorted by the values it holds rather- // than by the array Tabulator would otherwise compare as an object.- ...(type === "select" && isMulti && {- formatter: wrapFormatter(SelectValuesFormatter),+ // A set is shown as the chips it is edited as, whatever it holds — and sorted by those+ // values rather than by the array Tabulator would otherwise compare as an object.+ ...(isMulti && {+ editor: wrapEditor(ValuesEditor),+ formatter: wrapFormatter(ValuesFormatter),+ formatterParams: { type: type ?? "text" },sorter: (a, b) => joinValues(a).localeCompare(joinValues(b))})});@@ -349,54 +353,82 @@ function NoteFormatter({ cell }: FormatterOpts) {* hands no reference to the box it builds; the list then opens as it does for any focused combobox.*/function SelectEditor({ cell, success, editorParams }: EditorOpts) {- const { options, isMulti, onCreateOption } = editorParams as SelectEditorParams;+ const { options, onCreateOption } = editorParams as ValuesEditorParams;const containerRef = useRef<HTMLDivElement>(null);useEffect(() => containerRef.current?.querySelector("input")?.focus(), []);- // The set as it stands while the cell is open. Reporting each chip as it is taken would close the- // editor on the first one — `success` is Tabulator's "the edit is done" — so the set is held here- // and handed over once, when the field is left. A ref beside it because the handler below is- // bound once and would otherwise report the set the editor opened with.++ return (+ <div ref={containerRef} className="table-values-editor">+ <LabelValueInput+ labelType="select"+ value={cell.getValue() ?? ""}+ selectOptions={options}+ onCommit={success}+ onCreateOption={onCreateOption}+ />+ </div>+ );+}++/**+ * A cell holding several values is edited as the chips it shows: a select picks them from its+ * options, anything else takes what is typed. Either way the set is what is being edited, so the two+ * share everything around the field — how the set is gathered, and when it is handed over.+ *+ * Reporting a value as it is taken would close the editor on the first one — reporting is Tabulator's+ * "the edit is done" — so the set is held here and handed over once, when the cell is left.+ */+function ValuesEditor({ cell, success, editorParams }: EditorOpts) {+ const { labelType, options, onCreateOption } = editorParams as ValuesEditorParams;+ const containerRef = useRef<HTMLDivElement>(null);+ useEffect(() => containerRef.current?.querySelector("input")?.focus(), []);+const [ values, setValues ] = useState<string[]>(() => asValues(cell.getValue()));+ // The set as the handler below will read it. Written as the edit is made rather than left to the+ // next render, because leaving the field both takes what was typed and ends the edit — in that+ // order, and within the one event, which a value only reachable through a render would miss.const editedValues = useRef(values);- editedValues.current = values;+ function editValues(edited: string[]) {+ editedValues.current = edited;+ setValues(edited);+ }useEffect(() => {const editor = containerRef.current;- if (!isMulti || !editor) return;+ if (!editor) return;const onFocusOut = (e: FocusEvent) => {// Focus moving within the editor — the box to a chip's remove button, or back — is not- // leaving it. Picking from the list does not blur at all: the list keeps the focus in- // the box, which is what lets it stay open across picks.+ // leaving it. Picking from a list does not blur at all: the list keeps the focus in the+ // box, which is what lets it stay open across picks.if (e.relatedTarget instanceof Node && editor.contains(e.relatedTarget)) return;success(editedValues.current);};editor.addEventListener("focusout", onFocusOut);return () => editor.removeEventListener("focusout", onFocusOut);- }, [ isMulti, success ]);+ }, [ success ]);- // The editor grows downwards as chips are taken, which the pane the table scrolls in cuts off at+ // The editor grows downwards as values are taken, which the pane the table scrolls in cuts off at// its foot — on the last row there is nothing below the cell to grow into.const growsUpwards = useGrowsUpwards(containerRef);return (- <div ref={containerRef} className={clsx("table-select-editor", growsUpwards && "grows-upwards")}>- {isMulti ? (+ <div ref={containerRef} className={clsx("table-values-editor", growsUpwards && "grows-upwards")}>+ {labelType === "select" ? (<SelectValuesInputoptions={options}values={values}placeholder={t("promoted_attributes.select_values_placeholder")}onCreateOption={onCreateOption}- onCommit={setValues}+ onCommit={editValues}/>) : (- <LabelValueInput- labelType="select"- value={cell.getValue() ?? ""}- selectOptions={options}- onCommit={success}- onCreateOption={onCreateOption}+ <ValuesInput+ labelType={labelType === "relation" ? "text" : labelType}+ values={values}+ placeholder={t("promoted_attributes.values_placeholder")}+ onCommit={editValues}/>)}</div>@@ -404,16 +436,35 @@ function SelectEditor({ cell, success, editorParams }: EditorOpts) {}/** A multi-valued cell as the chips it is edited as, so reading and editing show the same set. */-function SelectValuesFormatter({ cell }: FormatterOpts) {+function ValuesFormatter({ cell, formatterParams }: FormatterOpts) {+ const { type } = formatterParams as { type?: ColumnType };return (- <span className="table-select-values">+ <span className="table-values">{asValues(cell.getValue()).map((value) => (- <span key={value} className="tn-chip">{value}</span>+ <span key={value} className="tn-chip"><span>{renderValue(value, type)}</span></span>))}</span>);}+/** The schemes that make a value of a link-like type clickable; a url carries its own. */+const LINK_SCHEMES: Partial<Record<ColumnType, string>> = { url: "", email: "mailto:", phone: "tel:" };++/**+ * One value of a set, read as its type reads it — so that a set of dates is as legible as a single+ * one, and a set of addresses is as clickable. Anything else is the value as stored.+ */+function renderValue(value: string, type: ColumnType | undefined) {+ if (type === "date" || type === "datetime") {+ return formatLabelDate(value, type === "datetime");+ }++ const scheme = type && LINK_SCHEMES[type];+ return scheme !== undefined+ ? <a href={applyLinkScheme(value, scheme)}>{value}</a>+ : value;+}+/*** A multi-valued cell's values. Stored as an array, but a cell can hold what an older single-valued* definition left behind, or nothing at all, so anything else is read as the set it stands for.@@ -429,11 +480,12 @@ function joinValues(value: unknown) {}/**- * What a select column hands its editor: the options it offers, whether it holds a set of them, and- * how to add one. A type rather than an interface so that it still reads as the loose record- * Tabulator types params as.+ * What a column hands its editor beyond the value: the kind of value it holds, and — a select being+ * the one type whose values are a closed set — the options it offers and how to add one. A type+ * rather than an interface so that it still reads as the loose record Tabulator types params as.*/-export type SelectEditorParams = {+export type ValuesEditorParams = {+ labelType: ColumnType;options: string[];isMulti?: boolean;/** Absent where the definition cannot be written to, which leaves the field a plain picker. */diff --git a/apps/client/src/widgets/collections/table/rows.spec.ts b/apps/client/src/widgets/collections/table/rows.spec.tsindex a9269da23c..ae19d17671 100644--- a/apps/client/src/widgets/collections/table/rows.spec.ts+++ b/apps/client/src/widgets/collections/table/rows.spec.ts@@ -23,4 +23,31 @@ describe("getAttributeDefinitionInformation", () => {{ name: "_TEST:TEST:TEST:Test1", type: "text" }]);});++ it("holds several values of the types a set means something for, and one of the rest", async () => {+ const note = buildNote({+ title: "Note 1",+ "#label:tags(inheritable)": "promoted,multi,text",+ "#label:due(inheritable)": "promoted,multi,date",+ "#label:site(inheritable)": "promoted,multi,url",+ "#label:status(inheritable)": "promoted,multi,select,options=Todo;Done",+ // A flag means what it means by being there at all, so several are the same one flag;+ // a colour is a single quality of the thing it describes.+ "#label:done(inheritable)": "promoted,multi,boolean",+ "#label:tint(inheritable)": "promoted,multi,color",+ "#label:owner(inheritable)": "promoted,single,text"+ });++ // Those left out still have a column — one holding the first value, as before they were+ // declared to hold many. They used to be dropped from the table altogether.+ expect(getAttributeDefinitionInformation(note)).toMatchObject([+ { name: "tags", type: "text", isMulti: true },+ { name: "due", type: "date", isMulti: true },+ { name: "site", type: "url", isMulti: true },+ { name: "status", type: "select", isMulti: true },+ { name: "done", type: "boolean", isMulti: false },+ { name: "tint", type: "color", isMulti: false },+ { name: "owner", type: "text", isMulti: false }+ ]);+ });});diff --git a/apps/client/src/widgets/collections/table/rows.ts b/apps/client/src/widgets/collections/table/rows.tsindex 54d0324fc0..6853f11c86 100644--- a/apps/client/src/widgets/collections/table/rows.ts+++ b/apps/client/src/widgets/collections/table/rows.ts@@ -91,14 +91,7 @@ export default function getAttributeDefinitionInformation(parentNote: FNote) {type = "relation";}- // A select is the one field a column can show several values in: its values are a set drawn- // from the options, which chips display and edit as the set it is. Any other type holds free- // text, for which a column has one cell and no way to tell one value from the next.- const isMulti = def.multiplicity === "multi";- if (isMulti && type !== "select") {- console.warn("Multiple values are not supported for now");- continue;- }+ const isMulti = def.multiplicity === "multi" && MULTI_VALUE_TYPES.has(type);info.push({name,@@ -110,3 +103,15 @@ export default function getAttributeDefinitionInformation(parentNote: FNote) {}return info;}++/**+ * The types a column can hold several values of, shown and edited as chips.+ *+ * The two left out are the ones a set says nothing for: a flag means what it means by being there at+ * all, so several of them are the same one flag; and a colour is a single quality of the thing it+ * describes. A column of either shows the first value it finds, as it did before it was declared to+ * hold many — better a value than a column that quietly goes missing.+ */+const MULTI_VALUE_TYPES = new Set<LabelType | "relation">([+ "text", "textarea", "number", "select", "date", "datetime", "time", "url", "email", "phone"+]);diff --git a/apps/client/src/widgets/react/Chip.css b/apps/client/src/widgets/react/Chip.cssindex 778fc1540c..c093b109ee 100644--- a/apps/client/src/widgets/react/Chip.css+++ b/apps/client/src/widgets/react/Chip.css@@ -1,3 +1,45 @@+/*+ * A field carrying chips ahead of the box typed into: the two are framed as one, so the chips read+ * as being in the field rather than stacked above it. The box gives up its own frame and takes what+ * room is left on the line, wrapping onto the next once the chips have filled it.+ */+.tn-chips-field {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 4px;+ padding: 3px 6px;+ border: 1px solid var(--main-border-color);+ border-radius: 6px;+ background: var(--input-background-color);++ &:focus-within {+ outline: 2px solid var(--input-focus-outline-color);+ }++ > input.form-control {+ flex: 1;+ min-width: 6ch;+ width: auto;+ padding: 2px 0;+ border: none;+ outline: none;++ &,+ &:hover,+ &:focus {+ background: transparent;+ }+ }++ /* A chip standing for a value holds text rather than a box to type in, so it needs none of the+ field styling the chip leaves to its contents — only room for the word itself. */+ > .tn-chip > span {+ padding-block: 2px;+ white-space: nowrap;+ }+}+/** One entry of a set: a rounded chip holding whatever it stands for, and a button removing it. The* chip is the surface — its contents give up borders and backgrounds of their own — so that a setdiff --git a/apps/client/src/widgets/react/FormAutocomplete.css b/apps/client/src/widgets/react/FormAutocomplete.cssindex 66b7e07cda..f94dbbd045 100644--- a/apps/client/src/widgets/react/FormAutocomplete.css+++ b/apps/client/src/widgets/react/FormAutocomplete.css@@ -1,38 +1,8 @@/*- * A field carrying chips ahead of the box typed into (see the component's `leading`): the two are- * framed as one, so the chips read as being in the field rather than stacked above it. The box gives- * up its own frame and takes what room is left on the line, wrapping onto the next once the chips- * have filled it.+ * A field carrying chips ahead of the box typed into (see the component's `leading`) looks the same+ * here as anywhere else a set is edited, so it wears the shared `tn-chips-field` and adds nothing of+ * its own. The class remains as the handle the dropdown is measured against.*/-.form-autocomplete-field {- display: flex;- flex-wrap: wrap;- align-items: center;- gap: 4px;- padding: 3px 6px;- border: 1px solid var(--main-border-color);- border-radius: 6px;- background: var(--input-background-color);-- &:focus-within {- outline: 2px solid var(--input-focus-outline-color);- }-- > input.form-control {- flex: 1;- min-width: 6ch;- width: auto;- padding: 2px 0;- border: none;- outline: none;-- &,- &:hover,- &:focus {- background: transparent;- }- }-}/** The suggestion list, dressed as one of the application's menus — the same metrics the mention listdiff --git a/apps/client/src/widgets/react/FormAutocomplete.tsx b/apps/client/src/widgets/react/FormAutocomplete.tsxindex 1c476cfb4b..b77604f443 100644--- a/apps/client/src/widgets/react/FormAutocomplete.tsx+++ b/apps/client/src/widgets/react/FormAutocomplete.tsx@@ -233,7 +233,7 @@ export default function FormAutocomplete({ currentValue, onChange, source, openOreturn (<>{leading !== undefined- ? <div ref={fieldRef} className="form-autocomplete-field">{leading}{field}</div>+ ? <div ref={fieldRef} className="tn-chips-field form-autocomplete-field">{leading}{field}</div>: field}{isOpen && items.length > 0 && position && createPortal(