Skip to content

Build your personal knowledge base with Trilium Notes

feat(attributes): let a field's values share the box's wrapping line

Elian Doran4e2fa5429c4b
diff --git a/apps/client/src/widgets/PromotedAttributes.css b/apps/client/src/widgets/PromotedAttributes.css
index 8afa5813e6..c94381b0ad 100644
--- a/apps/client/src/widgets/PromotedAttributes.css
+++ b/apps/client/src/widgets/PromotedAttributes.css
@@ -70,16 +70,12 @@ body.experimental-feature-new-layout .promoted-attributes-container {
* A label holding several values: one field carrying the whole set as chips, where the other kinds
* carry a single box. Laid out as the group around a single field is — the same gap after the name,
* the same height to sit against — so a note mixing the two reads as one grid rather than two.
- *
- * It is given room to grow across as well: chips take the width of the words on them, and a field
- * clamped to a box's width would wrap after the first of them.
*/
.promoted-attribute-cell > .promoted-attribute-values {
display: flex;
flex: 1;
align-items: center;
min-height: 40px;
- min-width: 250px;
margin-inline-start: 10px;
padding: 1px 0;
diff --git a/apps/client/src/widgets/attribute_widgets/values_input.css b/apps/client/src/widgets/attribute_widgets/values_input.css
index db56dbc48f..c39839b4a7 100644
--- a/apps/client/src/widgets/attribute_widgets/values_input.css
+++ b/apps/client/src/widgets/attribute_widgets/values_input.css
@@ -16,21 +16,16 @@
/*
* A field whose values are entered through a widget the browser brings: a calendar, a clock, a colour
- * dialog. Each asks for about the width of the field itself, so a value sharing the line with one
- * would be squeezed to nothing — the values take a line each instead, under the widget.
+ * dialog. The values share the field's line with the box they are entered in, and wrap onto the next
+ * once it is full, as they do for any other type — all that differs is which end the box sits at.
*/
-.values-input.stacked {
- flex-direction: column;
- /* Each value only as wide as the word on it: stretched to the field, one would read as a row of
- the table rather than as one of several held in a cell. */
- align-items: flex-start;
-
+.values-input.entry-leads {
/*
- * The widget leads and the values follow, rather than the other way about. Not for the reading of
- * it: a box at the foot of a growing stack moves down with every value taken, and a browser keeps
- * the box being typed in in view by scrolling whatever it sits in — which in a table is the pane
- * the rows scroll in, and scrolling that hands the row being edited back to be rendered afresh,
- * editor and all. Kept at the head, it does not move, and nothing is scrolled.
+ * The box leads and the values follow, rather than the other way about. Not for the reading of it:
+ * a box after a growing set of values moves along with every one taken, and a browser keeps the
+ * box being typed in in view by scrolling whatever it sits in — which in a table is the pane the
+ * rows scroll in, and scrolling that hands the row being edited back to be rendered afresh, editor
+ * and all. Kept at the head, it does not move, and nothing is scrolled.
*/
> .values-input-entry {
order: -1;
@@ -40,13 +35,17 @@
}
/*
- * The box a value is entered into, told apart from the values already taken. Those are chips lying
- * on the field's own surface, so a box with neither edge nor ground of its own reads as a gap
- * between them rather than as somewhere to type — the more so for a widget, which draws only its
- * own placeholder until something is entered.
+ * The box a value is entered into, told apart from the values beside it. Those are chips lying on
+ * the field's own surface, so a box with neither edge nor ground of its own reads as a gap between
+ * them rather than as somewhere to type — the more so for a widget, which draws only its own
+ * placeholder until something is entered.
*/
.form-control:not([type="color"]) {
+ /* As wide as the widget in it needs and no wider. Said again here because the box is wrapped
+ up with its button rather than sitting in the field itself, which puts it out of reach of
+ the field's own rule — leaving it the full width Bootstrap gives a form control. */
flex: 0 1 auto;
+ width: auto;
background-color: var(--input-background-color);
border: 1px solid var(--main-border-color);
border-radius: var(--badge-radius, 12px);
diff --git a/apps/client/src/widgets/attribute_widgets/values_input.tsx b/apps/client/src/widgets/attribute_widgets/values_input.tsx
index 572ff45fed..74f10fb8aa 100644
--- a/apps/client/src/widgets/attribute_widgets/values_input.tsx
+++ b/apps/client/src/widgets/attribute_widgets/values_input.tsx
@@ -113,10 +113,10 @@ export default function ValuesInput({ labelType, values, onCommit, renderValue,
}
return (
- // A widget of the browser's own asks for the width of a calendar or a clock, which leaves a
- // chip beside it too little to be read — so where the field is one of those, the chips stack
- // above it instead of sharing its line.
- <div className={clsx("tn-field values-input", PICKED_TYPES.has(labelType) && "stacked")}>
+ // Values and the box they are entered in share the one wrapping line, however they are
+ // entered. Where a widget of the browser's own is what enters them, the box leads rather than
+ // follows — see below.
+ <div className={clsx("tn-field values-input", PICKED_TYPES.has(labelType) && "entry-leads")}>
{values.map((value) => (
<Chip
key={value}
@@ -127,14 +127,14 @@ export default function ValuesInput({ labelType, values, onCommit, renderValue,
<span>{renderValue ? renderValue(value) : value}</span>
</Chip>
))}
- {/* The box and the button that asks for what it holds are one thing on the page, so where
- the values are stacked they are wrapped as one — the alternative, laying the button
- over the field, puts it on whatever the widget's own width happens to reach.
+ {/* The box and the button that asks for what it holds are one thing on the page, so they
+ are wrapped as one: whatever wraps or is ordered, they go together, and the button
+ never ends up on a line without the box it belongs to.
Keyed, as the chips before them are: a field of keyed and unkeyed siblings together is
matched up by position as it grows, so taking a second value would rebuild the box
rather than keep it — losing the focus in it, and with it the widget it had open. */}
- <Entry stacked={PICKED_TYPES.has(labelType)}>
+ <Entry grouped={PICKED_TYPES.has(labelType)}>
{isColor ? (
<input
key="field"
@@ -191,10 +191,9 @@ export default function ValuesInput({ labelType, values, onCommit, renderValue,
const PICKED_TYPES = new Set<LabelType>([ "color", "date", "datetime", "time" ]);
/**
- * The box and the button beside it, held together where the values above them are stacked a line
- * each — a column would otherwise put the button on a line of its own. Where they share the line with
- * the values there is nothing to hold: they are already side by side.
+ * The box and the button beside it, held together as the one thing they are, so that the pair moves
+ * and wraps as a pair. Where there is no button there is nothing to hold: the box is the whole of it.
*/
-function Entry({ stacked, children }: { stacked: boolean; children: ComponentChildren }) {
- return stacked ? <div className="values-input-entry">{children}</div> : <>{children}</>;
+function Entry({ grouped, children }: { grouped: boolean; children: ComponentChildren }) {
+ return grouped ? <div className="values-input-entry">{children}</div> : <>{children}</>;
}