refactor: improve context menu performance

- extract menu from rundown tree
- lazy create actions
This commit is contained in:
Carlos Valente
2026-01-06 17:07:01 +01:00
committed by Carlos Valente
parent 8e32314667
commit 1f8065143a
6 changed files with 24 additions and 26 deletions
@@ -1,4 +1,3 @@
import type { PropsWithChildren } from 'react';
import { create } from 'zustand';
import { DropdownMenuOption, PositionedDropdownMenu } from '../../../common/components/dropdown-menu/DropdownMenu';
@@ -24,7 +23,7 @@ export const useContextMenuStore = create<ContextMenuStore>((set) => ({
setIsOpen: (newIsOpen) => set(() => ({ isOpen: newIsOpen })),
}));
export function RundownContextMenu({ children }: PropsWithChildren) {
export function RundownContextMenu() {
const { position, options, isOpen, setIsOpen } = useContextMenuStore();
const onClose = () => {
@@ -32,13 +31,8 @@ export function RundownContextMenu({ children }: PropsWithChildren) {
};
if (!isOpen) {
return children;
return null;
}
return (
<>
{children}
<PositionedDropdownMenu isOpen position={position} onClose={onClose} items={options} />
</>
);
return <PositionedDropdownMenu isOpen position={position} onClose={onClose} items={options} />;
}