fix(data-grid): scope SQL extractors to active context
This commit is contained in:
4 files changed
+143
-9
No files matched your search
@@ -724,12 +724,25 @@ const contextSelectionIsSynthetic = ref(false);
|
||||
const contextHeaderColumn = ref<string | null>(null);
|
||||
const contextHeaderColumnIndex = ref<number | null>(null);
|
||||
const contextHeaderVisibleColIdx = ref<number | null>(null);
|
||||
let contextMenuLifecycle = 0;
|
||||
|
||||
function invalidateSyntheticContextSelection() {
|
||||
contextSelectionIsSynthetic.value = false;
|
||||
contextCell.value = null;
|
||||
}
|
||||
|
||||
function onGridContextMenuOpen() {
|
||||
contextMenuLifecycle += 1;
|
||||
}
|
||||
|
||||
function onGridContextMenuClose() {
|
||||
const lifecycle = ++contextMenuLifecycle;
|
||||
queueMicrotask(() => {
|
||||
if (lifecycle !== contextMenuLifecycle) return;
|
||||
invalidateSyntheticContextSelection();
|
||||
});
|
||||
}
|
||||
|
||||
const bulkEditDialogOpen = ref(false);
|
||||
const bulkEditValue = ref("");
|
||||
const copyColumnNamesDialogOpen = ref(false);
|
||||
@@ -10328,7 +10341,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
|
||||
@paste="onGridPaste"
|
||||
@focusin="onGridFocusIn"
|
||||
>
|
||||
<CustomContextMenu :items="gridContextMenuItems" v-slot="{ onContextMenu }">
|
||||
<CustomContextMenu :items="gridContextMenuItems" @open="onGridContextMenuOpen" @close="onGridContextMenuClose" v-slot="{ onContextMenu }">
|
||||
<div v-if="hasData || canShowWhereSearch" class="flex-1 flex flex-col overflow-hidden" @contextmenu="onContextMenu">
|
||||
<!-- Search bar -->
|
||||
<!-- Leave real vertical space around the 28px controls instead of fitting them against the border. -->
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const source = readFileSync(new URL("../DataGrid.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("DataGrid context extractor lifecycle", () => {
|
||||
it("clears the right-click target after the context-menu action has started", () => {
|
||||
expect(source).toContain('@open="onGridContextMenuOpen"');
|
||||
expect(source).toContain('@close="onGridContextMenuClose"');
|
||||
expect(source).toContain("queueMicrotask(() => {");
|
||||
expect(source).toContain("invalidateSyntheticContextSelection();");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user