Skip to content

Build your personal knowledge base with Trilium Notes

fix(badges): keep the "Web clip" details open for a click inside

Elian Doranf1c6f3e5e6ae
diff --git a/apps/client/src/widgets/layout/NoteBadges.spec.tsx b/apps/client/src/widgets/layout/NoteBadges.spec.tsx
index 1f6ab8dc28..f949a96dd3 100644
--- a/apps/client/src/widgets/layout/NoteBadges.spec.tsx
+++ b/apps/client/src/widgets/layout/NoteBadges.spec.tsx
@@ -100,6 +100,14 @@ describe("ClippedNoteBadge", () => {
]);
});
+ it("stays open for a click inside, so its text can be selected", async () => {
+ const details = await openDetails({ "#pageUrl": PAGE_URL, "#pageAuthor": "Ada Lovelace" });
+
+ act(() => details.querySelector("dd")?.click());
+ await new Promise((resolve) => setTimeout(resolve));
+ expect(document.querySelector(".tn-popup .clipped-note-details")).not.toBeNull();
+ });
+
it("lists the dates of a page that has no description", async () => {
const details = await openDetails({ "#pageUrl": PAGE_URL, "#modifiedDate": "2024-06-12" });
diff --git a/apps/client/src/widgets/react/Badge.tsx b/apps/client/src/widgets/react/Badge.tsx
index f6bda49437..ecea37c23e 100644
--- a/apps/client/src/widgets/react/Badge.tsx
+++ b/apps/client/src/widgets/react/Badge.tsx
@@ -147,7 +147,10 @@ function htmlToText(html: string) {
export function BadgeWithDropdown({ text, children, tooltip, className, dropdownProps, panel, ...props }: BadgeProps & {
children?: ComponentChildren,
dropdownProps?: Partial<DropdownPanelProps>,
- /** Opens a {@link DropdownPanel} instead of a menu, for content other than menu rows. */
+ /**
+ * Opens a {@link DropdownPanel} instead of a menu, for content other than menu rows. It closes
+ * only on a click outside, so its text can be selected.
+ */
panel?: boolean
}) {
const Toggle = panel ? DropdownPanel : Dropdown;
@@ -166,6 +169,7 @@ export function BadgeWithDropdown({ text, children, tooltip, className, dropdown
hideToggleArrow
title={tooltip}
titlePosition="bottom"
+ autoClose={panel ? "outside" : undefined}
{...dropdownProps}
placement="bottom"
>{children}</Toggle>