fix(editor): keep batch column session across empty results
This commit is contained in:
2 files changed
+28
-3
No files matched your search
+17
-2
@@ -91,8 +91,23 @@ describe("QueryEditor batch selection ownership", () => {
|
||||
batch.toggleAllBatchColumnSelection(currentView, session.key);
|
||||
expect(next.selectedKeys.size).toBe(0);
|
||||
expect(next.completionOptions.size).toBe(0);
|
||||
batch.prepareBatchColumnSelectionSession([], next.document, next.from, next.to);
|
||||
expect(batch.expandedRendering).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the checked fields when a sibling result carries no column candidates (dbx#9973)", () => {
|
||||
const { batch, session, items, currentView, row } = createHarness();
|
||||
batch.toggleAllBatchColumnSelection(currentView, session.key);
|
||||
// One completion request builds several result sets and only some of them
|
||||
// carry column candidates. The empty one must not drop the session that the
|
||||
// rendered checkbox rows still point at.
|
||||
expect(batch.prepareBatchColumnSelectionSession([], session.document, session.from, session.to)).toBeNull();
|
||||
expect(batch.expandedRendering).toBe(true);
|
||||
expect(batch.prepareBatchColumnSelectionSession(items, session.document, session.from, session.to)).toBe(session);
|
||||
expect(session.selectedKeys).toEqual(new Set(session.candidates.map((candidate) => candidate.key)));
|
||||
const { checkbox } = row(0);
|
||||
expect(checkbox.checked).toBe(true);
|
||||
checkbox.dispatchEvent(new PointerEvent("pointerdown", { button: 0, buttons: 1, isPrimary: true, pointerId: 5, bubbles: true }));
|
||||
expect(session.selectedKeys.has(session.candidates[0].key)).toBe(false);
|
||||
document.body.style.userSelect = "";
|
||||
});
|
||||
|
||||
it("guards label clicks and applies checked fields together, never an individual row", () => {
|
||||
|
||||
@@ -254,7 +254,17 @@ export function useQueryEditorBatchSelection(options: QueryEditorBatchSelectionO
|
||||
function prepareBatchColumnSelectionSession(items: SqlCompletionItem[], document: string, from: number, to: number): BatchColumnSelectionSession | null {
|
||||
const selectableItems = items.filter((item) => item.type === "column" && item.batchSelectionMode && item.apply);
|
||||
if (selectableItems.length === 0) {
|
||||
clearBatchColumnSelectionSession();
|
||||
// One completion request builds several result sets (the local pass plus
|
||||
// the metadata pass) and only some of them carry column candidates.
|
||||
// Clearing the stored session for such an empty sibling result left the
|
||||
// checkbox rows rendered by the other result attached to a session that
|
||||
// no longer existed, so clicking a checkbox did nothing. It also made the
|
||||
// expanded-rendering flag flap false→true on every pass, reconfiguring
|
||||
// CodeMirror's autocompletion compartment while a source was still
|
||||
// pending; the recreated list stayed disabled (ArrowUp/Down ignored, then
|
||||
// closed on the next caret move). Keep the session and only report "no
|
||||
// batch selection" for this result (dbx#9973). The session is still
|
||||
// dropped when the popup closes, on Escape and after an accepted row.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user