diff --git a/apps/client/src/widgets/note_icon.tsx b/apps/client/src/widgets/note_icon.tsx index 7729d6185..45e721e21 100644 --- a/apps/client/src/widgets/note_icon.tsx +++ b/apps/client/src/widgets/note_icon.tsx @@ -1,7 +1,9 @@ import "./note_icon.css"; import { IconRegistry } from "@triliumnext/commons"; +import { Dropdown as BootstrapDropdown } from "bootstrap"; import { t } from "i18next"; +import { RefObject } from "preact"; import { useEffect, useRef, useState } from "preact/hooks"; import FNote from "../entities/fnote"; @@ -29,6 +31,7 @@ export default function NoteIcon() { const [ icon, setIcon ] = useState(); const [ iconClass ] = useNoteLabel(note, "iconClass"); const [ workspaceIconClass ] = useNoteLabel(note, "workspaceIconClass"); + const dropdownRef = useRef(null); useEffect(() => { setIcon(note?.getIcon()); @@ -38,18 +41,22 @@ export default function NoteIcon() { - { note && } + { note && } ); } -function NoteIconList({ note }: { note: FNote }) { +function NoteIconList({ note, dropdownRef }: { + note: FNote, + dropdownRef: RefObject; +}) { const searchBoxRef = useRef(null); const [ search, setSearch ] = useState(); const [ iconData, setIconData ] = useState(); @@ -135,6 +142,7 @@ function NoteIconList({ note }: { note: FNote }) { const attributeToSet = note.hasOwnedLabel("workspace") ? "workspaceIconClass" : "iconClass"; attributes.setLabel(note.noteId, attributeToSet, iconClass); } + dropdownRef?.current?.hide(); }} > {getIconLabels(note).length > 0 && ( @@ -148,6 +156,7 @@ function NoteIconList({ note }: { note: FNote }) { for (const label of getIconLabels(note)) { attributes.removeAttributeById(note.noteId, label.attributeId); } + dropdownRef?.current?.hide(); }} />