mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-11 17:19:34 +00:00
refactor: improve context menu performance
- extract menu from rundown tree - lazy create actions
This commit is contained in:
committed by
Carlos Valente
parent
8e32314667
commit
1f8065143a
@@ -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} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user