fix(promoted_attributes): value carrying over onto new notes

This commit is contained in:
Elian Doran 2025-12-01 13:30:03 +02:00
parent 3051664228
commit 98241fb54b
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View File

@ -207,7 +207,7 @@ function toObject<T, R>(array: T[], fn: (arg0: T) => [key: string, value: R]) {
return obj; return obj;
} }
function randomString(len: number) { export function randomString(len: number) {
let text = ""; let text = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

View File

@ -14,8 +14,10 @@ import ws from "../services/ws";
import { UpdateAttributeResponse } from "@triliumnext/commons"; import { UpdateAttributeResponse } from "@triliumnext/commons";
import attributes from "../services/attributes"; import attributes from "../services/attributes";
import debounce from "../services/debounce"; import debounce from "../services/debounce";
import { randomString } from "../services/utils";
interface Cell { interface Cell {
uniqueId: string;
definitionAttr: FAttribute; definitionAttr: FAttribute;
definition: DefinitionObject; definition: DefinitionObject;
valueAttr: Attribute; valueAttr: Attribute;
@ -44,6 +46,7 @@ export default function PromotedAttributes() {
<div className="promoted-attributes-widget"> <div className="promoted-attributes-widget">
{cells && cells.length > 0 && <div className="promoted-attributes-container"> {cells && cells.length > 0 && <div className="promoted-attributes-container">
{note && cells?.map(cell => <PromotedAttributeCell {note && cells?.map(cell => <PromotedAttributeCell
key={cell.uniqueId}
cell={cell} cell={cell}
cells={cells} setCells={setCells} cells={cells} setCells={setCells}
shouldFocus={cell === cellToFocus} setCellToFocus={setCellToFocus} shouldFocus={cell === cellToFocus} setCellToFocus={setCellToFocus}
@ -103,7 +106,8 @@ function usePromotedAttributeData(note: FNote | null | undefined, componentId: s
valueAttr.attributeId = ""; valueAttr.attributeId = "";
} }
cells.push({ definitionAttr, definition, valueAttr, valueName }); const uniqueId = randomString(10);
cells.push({ definitionAttr, definition, valueAttr, valueName, uniqueId });
} }
} }
setCells(cells); setCells(cells);