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
fix(promoted attributes): show one color picker on a color field
Elian Doranebef50be8533
diff --git a/apps/client/src/widgets/PromotedAttributes.spec.tsx b/apps/client/src/widgets/PromotedAttributes.spec.tsxindex 189ba299d9..f7e146d5ea 100644--- a/apps/client/src/widgets/PromotedAttributes.spec.tsx+++ b/apps/client/src/widgets/PromotedAttributes.spec.tsx@@ -436,12 +436,15 @@ describe("PromotedAttributesContent rendering", () => {expect(unchecked.querySelector<HTMLInputElement>("input[type=checkbox]")?.checked).toBe(false);});- it("renders the colour picker alongside a colour attribute", async () => {+ it("renders a single colour picker for a colour attribute", async () => {const container = await renderCells(note, [buildCell(note, { definition: { labelType: "color" }, value: "#123456" })]);- expect(container.querySelector(".color-picker")).not.toBeNull();+ const pickers = container.querySelectorAll<HTMLInputElement>("input[type=color]");+ expect(pickers).toHaveLength(1);+ expect(pickers[0]?.value).toBe("#123456");+ expect(container.querySelector(".color-picker")).toBeNull();// The raw input is kept but hidden, the picker drives the value.expect(container.querySelector("input.promoted-attribute-input")?.getAttribute("type")).toBe("hidden");});diff --git a/apps/client/src/widgets/PromotedAttributes.tsx b/apps/client/src/widgets/PromotedAttributes.tsxindex 3b31f187aa..cec07ebccc 100644--- a/apps/client/src/widgets/PromotedAttributes.tsx+++ b/apps/client/src/widgets/PromotedAttributes.tsx@@ -17,7 +17,6 @@ import ws from "../services/ws";import LabelValueInput, { useLabelValueSuggestions } from "./attribute_widgets/label_value_input";import MultiValueInput from "./attribute_widgets/multi_value_input";import RelationValuesInput from "./attribute_widgets/relation_values_input";-import ColorPicker from "./react/ColorPicker";import FormAutocomplete from "./react/FormAutocomplete";import { useNoteContext, useNoteLabel, useTriliumEvent, useUniqueName } from "./react/hooks";import NoteAutocomplete from "./react/NoteAutocomplete";@@ -272,17 +271,7 @@ function LabelInput(props: CellProps & { inputId: string }) {<label for={inputId}>{definition.promotedAlias ?? valueName}</label></>;}- return (- <div className="input-group">- {input}- { definition.labelType === "color" && (- <ColorPicker- currentValue={valueAttr.value || null}- onChange={(color) => updateAttribute(note, cell, componentId, color ?? "", setCells)}- />- )}- </div>- );+ return <div className="input-group">{input}</div>;}/**