Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: right click on request opens far to the right #8181 #8234

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ interface Props {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
onRename: () => void;
contextMenuPosition: { x: number | null; y: number | null };
setContextMenuPosition: (position: { x: number | null; y: number | null }) => void;
}

export const RequestActionsDropdown = ({
Expand All @@ -48,6 +50,8 @@ export const RequestActionsDropdown = ({
isOpen,
onOpenChange,
onRename,
contextMenuPosition,
setContextMenuPosition,
}: Props) => {
const {
settings,
Expand Down Expand Up @@ -265,6 +269,7 @@ export const RequestActionsDropdown = ({
<MenuTrigger
isOpen={isOpen}
onOpenChange={isOpen => {
setContextMenuPosition({ x: null, y: null });
isOpen && onOpen();
onOpenChange(isOpen);
}}
Expand All @@ -283,6 +288,7 @@ export const RequestActionsDropdown = ({
onAction={key => requestActionList.find(i => i.items.find(a => a.id === key))?.items.find(a => a.id === key)?.action()}
items={requestActionList}
className="border select-none text-sm min-w-max border-solid border-[--hl-sm] shadow-lg bg-[--color-bg] py-2 rounded-md overflow-y-auto max-h-[85vh] focus:outline-none"
style={(contextMenuPosition.x && contextMenuPosition.y) ? { position: 'fixed', top: contextMenuPosition.y, left: contextMenuPosition.x } : {}}
>
{section => (
<Section className='flex-1 flex flex-col'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ interface Props extends Partial<DropdownProps> {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
onRename: () => void;
contextMenuPosition: { x: number | null; y: number | null };
setContextMenuPosition: (position: { x: number | null; y: number | null }) => void;
}

export const RequestGroupActionsDropdown = ({
requestGroup,
isOpen,
onOpenChange,
onRename,
contextMenuPosition,
setContextMenuPosition,
}: Props) => {
const {
activeProject,
Expand Down Expand Up @@ -295,6 +299,7 @@ export const RequestGroupActionsDropdown = ({
isOpen={isOpen}
onOpenChange={isOpen => {
isOpen && onOpen();
setContextMenuPosition({ x: null, y: null });
onOpenChange(isOpen);
}}
>
Expand All @@ -312,6 +317,7 @@ export const RequestGroupActionsDropdown = ({
onAction={key => requestGroupActionItems.find(i => i.items.find(a => a.id === key))?.items.find(a => a.id === key)?.action()}
items={requestGroupActionItems}
className="border select-none text-sm min-w-max border-solid border-[--hl-sm] shadow-lg bg-[--color-bg] py-2 rounded-md overflow-y-auto max-h-[85vh] focus:outline-none"
style={(contextMenuPosition.x && contextMenuPosition.y) ? { position: 'fixed', top: contextMenuPosition.y, left: contextMenuPosition.x } : {}}
>
{section => (
<Section className='flex-1 flex flex-col'>
Expand Down
6 changes: 6 additions & 0 deletions packages/insomnia/src/ui/routes/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ const CollectionGridListItem = ({
}): React.ReactNode => {
const [isEditable, setIsEditable] = useState(false);
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
const [contextMenuPosition, setContextMenuPostion] = useState<{ x: number | null; y: number | null }>({ x: null, y: null });

const action = isRequestGroup(item.doc) ? `/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/debug/request-group/${item.doc._id}/update` : `/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/debug/request/${item.doc._id}/update`;

Expand All @@ -1250,6 +1251,7 @@ const CollectionGridListItem = ({
onContextMenu={e => {
e.preventDefault();
setIsContextMenuOpen(true);
setContextMenuPostion({ x: e.clientX, y: e.clientY });
}}
onDoubleClick={() => setIsEditable(true)}
data-selected={isSelected}
Expand Down Expand Up @@ -1324,6 +1326,8 @@ const CollectionGridListItem = ({
onRename={() => setIsEditable(true)}
isOpen={isContextMenuOpen}
onOpenChange={setIsContextMenuOpen}
contextMenuPosition={contextMenuPosition}
setContextMenuPosition={setContextMenuPostion}
/>
) : (
<RequestActionsDropdown
Expand All @@ -1334,6 +1338,8 @@ const CollectionGridListItem = ({
isPinned={item.pinned}
isOpen={isContextMenuOpen}
onOpenChange={setIsContextMenuOpen}
contextMenuPosition={contextMenuPosition}
setContextMenuPosition={setContextMenuPostion}
/>
)}
</div>
Expand Down
Loading