Preserve sidebar item active color when showing context menu

This commit is contained in:
Gregory Schier
2026-01-03 15:07:29 -08:00
parent c75d6b815e
commit 58bf55704a
2 changed files with 12 additions and 1 deletions

View File

@@ -235,6 +235,12 @@ function TreeItem_<T extends { id: string }>({
e.preventDefault();
e.stopPropagation();
// Set data attribute on the list item to preserve active state
if (listItemRef.current) {
listItemRef.current.setAttribute('data-context-menu-open', 'true');
}
const items = await getContextMenu(node.item);
setShowContextMenu({ items, x: e.clientX ?? 100, y: e.clientY ?? 100 });
},
@@ -242,6 +248,10 @@ function TreeItem_<T extends { id: string }>({
);
const handleCloseContextMenu = useCallback(() => {
// Remove data attribute when context menu closes
if (listItemRef.current) {
listItemRef.current.removeAttribute('data-context-menu-open');
}
setShowContextMenu(null);
}, []);