fix(downloads): keep the column menu open on right click
Stop the header context event before it reaches the newly mounted outside-click listener, preventing the column menu from closing in the same native event.
This commit is contained in:
@@ -549,7 +549,7 @@ export function DownloadsTableHeader({ actions, columnOrder, gridTemplate, sortC
|
|||||||
className="downloads-column-header"
|
className="downloads-column-header"
|
||||||
data-download-column={column}
|
data-download-column={column}
|
||||||
key={column}
|
key={column}
|
||||||
onContextMenu={(event) => { event.preventDefault(); actions.onColumnContextMenu(column, event.clientX, event.clientY); }}
|
onContextMenu={(event) => { event.preventDefault(); event.stopPropagation(); actions.onColumnContextMenu(column, event.clientX, event.clientY); }}
|
||||||
onPointerCancel={(event) => actions.onColumnPointerCancel(column, event)}
|
onPointerCancel={(event) => actions.onColumnPointerCancel(column, event)}
|
||||||
onPointerDown={(event) => {
|
onPointerDown={(event) => {
|
||||||
if (event.button !== 0 || !event.isPrimary) return;
|
if (event.button !== 0 || !event.isPrimary) return;
|
||||||
|
|||||||
@@ -1572,6 +1572,28 @@ describe("download table row contracts", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("opens the column menu without letting the same context event close it again", () => {
|
||||||
|
const calls: Array<[string, number, number]> = [];
|
||||||
|
const header = DownloadsTableHeader({
|
||||||
|
actions: createActions({ onColumnContextMenu: (column, x, y) => calls.push([column, x, y]) }),
|
||||||
|
columnOrder: ["name", "size"],
|
||||||
|
gridTemplate: "200px 100px",
|
||||||
|
selectedCount: 0,
|
||||||
|
sortColumn: "name",
|
||||||
|
sortDirection: "asc",
|
||||||
|
visibleIds: []
|
||||||
|
});
|
||||||
|
const nameHeader = findElement(header, (element) => element.props["data-download-column"] === "name");
|
||||||
|
const preventDefault = vi.fn();
|
||||||
|
const stopPropagation = vi.fn();
|
||||||
|
|
||||||
|
nameHeader.props.onContextMenu({ clientX: 320, clientY: 140, preventDefault, stopPropagation });
|
||||||
|
|
||||||
|
expect(preventDefault).toHaveBeenCalledTimes(1);
|
||||||
|
expect(stopPropagation).toHaveBeenCalledTimes(1);
|
||||||
|
expect(calls).toEqual([["name", 320, 140]]);
|
||||||
|
});
|
||||||
|
|
||||||
it("ignores another column move while the previous move is settling", () => {
|
it("ignores another column move while the previous move is settling", () => {
|
||||||
const calls: string[] = [];
|
const calls: string[] = [];
|
||||||
const header = DownloadsTableHeader({
|
const header = DownloadsTableHeader({
|
||||||
|
|||||||
Reference in New Issue
Block a user