mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 22:40:26 +01:00
Preserve sidebar item active color when showing context menu
This commit is contained in:
@@ -679,7 +679,8 @@ function TreeInner<T extends { id: string }>(
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
'[&_.tree-item.selected_.tree-item-inner]:text-text',
|
'[&_.tree-item.selected_.tree-item-inner]:text-text',
|
||||||
'[&:focus-within]:[&_.tree-item.selected]:bg-surface-active',
|
'[&:focus-within]:[&_.tree-item.selected]:bg-surface-active',
|
||||||
'[&:not(:focus-within)]:[&_.tree-item.selected]:bg-surface-highlight',
|
'[&:not(:focus-within)]:[&_.tree-item.selected:not([data-context-menu-open])]:bg-surface-highlight',
|
||||||
|
'[&_.tree-item.selected[data-context-menu-open]]:bg-surface-active',
|
||||||
// Round the items, but only if the ends of the selection.
|
// Round the items, but only if the ends of the selection.
|
||||||
// Also account for the drop marker being in between items
|
// Also account for the drop marker being in between items
|
||||||
'[&_.tree-item]:rounded-md',
|
'[&_.tree-item]:rounded-md',
|
||||||
|
|||||||
@@ -235,6 +235,12 @@ function TreeItem_<T extends { id: string }>({
|
|||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
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);
|
const items = await getContextMenu(node.item);
|
||||||
setShowContextMenu({ items, x: e.clientX ?? 100, y: e.clientY ?? 100 });
|
setShowContextMenu({ items, x: e.clientX ?? 100, y: e.clientY ?? 100 });
|
||||||
},
|
},
|
||||||
@@ -242,6 +248,10 @@ function TreeItem_<T extends { id: string }>({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleCloseContextMenu = useCallback(() => {
|
const handleCloseContextMenu = useCallback(() => {
|
||||||
|
// Remove data attribute when context menu closes
|
||||||
|
if (listItemRef.current) {
|
||||||
|
listItemRef.current.removeAttribute('data-context-menu-open');
|
||||||
|
}
|
||||||
setShowContextMenu(null);
|
setShowContextMenu(null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user