fix context menu original item

This commit is contained in:
Kendall Garner 2024-08-27 21:21:44 -07:00
parent 62c372d0c7
commit 43fe1a235e
No known key found for this signature in database
GPG key ID: 18D2767419676C87

View file

@ -137,7 +137,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
} = args; } = args;
const serverType = data[0]?.serverType || useAuthStore.getState().currentServer?.type; const serverType = data[0]?.serverType || useAuthStore.getState().currentServer?.type;
let validMenuItems = menuItems; let validMenuItems = menuItems.filter((item) => !disabledItems[item.id]);
if (serverType === ServerType.JELLYFIN) { if (serverType === ServerType.JELLYFIN) {
validMenuItems = menuItems.filter( validMenuItems = menuItems.filter(
@ -147,7 +147,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
// If the context menu dimension can't be automatically calculated, calculate it manually // If the context menu dimension can't be automatically calculated, calculate it manually
// This is a hacky way since resize observer may not automatically recalculate when not rendered // This is a hacky way since resize observer may not automatically recalculate when not rendered
const menuHeight = menuRect.height || (menuItems.length + 1) * 50; const menuHeight = menuRect.height || (validMenuItems.length + 1) * 40;
const menuWidth = menuRect.width || 220; const menuWidth = menuRect.width || 220;
const shouldReverseY = yPos + menuHeight > viewport.height; const shouldReverseY = yPos + menuHeight > viewport.height;
@ -169,7 +169,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
}); });
setOpened(true); setOpened(true);
}, },
[menuRect.height, menuRect.width, setCtx, viewport.height, viewport.width], [disabledItems, menuRect.height, menuRect.width, setCtx, viewport.height, viewport.width],
); );
const closeContextMenu = useCallback(() => { const closeContextMenu = useCallback(() => {
@ -929,8 +929,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
> >
{ctx.menuItems?.map((item) => { {ctx.menuItems?.map((item) => {
return ( return (
!contextMenuItems[item.id].disabled && !contextMenuItems[item.id].disabled && (
!disabledItems[item.id] && (
<Fragment key={`context-menu-${item.id}`}> <Fragment key={`context-menu-${item.id}`}>
{item.children ? ( {item.children ? (
<HoverCard <HoverCard