mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-18 14:59:42 +02:00
Content menu on entire sidebar
This commit is contained in:
@@ -419,6 +419,19 @@ export function Sidebar({ className }: Props) {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [showMainContextMenu, setShowMainContextMenu] = useState<{
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
const handleMainContextMenu = useCallback((e: React.MouseEvent<HTMLElement>) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
setShowMainContextMenu({ x: e.clientX, y: e.clientY });
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const mainContextMenuItems = useCreateDropdownItems();
|
||||||
|
|
||||||
// Not ready to render yet
|
// Not ready to render yet
|
||||||
if (tree == null || collapsed.value == null) {
|
if (tree == null || collapsed.value == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -431,11 +444,17 @@ export function Sidebar({ className }: Props) {
|
|||||||
onFocus={handleFocus}
|
onFocus={handleFocus}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
tabIndex={hidden ? -1 : 0}
|
tabIndex={hidden ? -1 : 0}
|
||||||
|
onContextMenu={handleMainContextMenu}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
className,
|
className,
|
||||||
'h-full pb-3 overflow-y-scroll overflow-x-visible hide-scrollbars pt-2',
|
'h-full pb-3 overflow-y-scroll overflow-x-visible hide-scrollbars pt-2',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
<ContextMenu
|
||||||
|
show={showMainContextMenu}
|
||||||
|
items={mainContextMenuItems}
|
||||||
|
onClose={() => setShowMainContextMenu(null)}
|
||||||
|
/>
|
||||||
<SidebarItems
|
<SidebarItems
|
||||||
treeParentMap={treeParentMap}
|
treeParentMap={treeParentMap}
|
||||||
selectedId={selectedId}
|
selectedId={selectedId}
|
||||||
|
|||||||
Reference in New Issue
Block a user