fix(grid): 修复右键菜单选择时的单元格清理逻辑

感谢 @eryajf 的贡献!
This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-06-09 15:45:20 +08:00
1 parent 9c8a1c62b7
commit 7798f2231e
2 files changed
+33 -1

No files matched your search

@@ -5178,6 +5178,7 @@ function onCellContext(rowId: number, rowIndex: number, colIdx: number, visibleC
contextHeaderColumnIndex.value = null;
contextCell.value = { rowId, rowIndex, col: colIdx };
if (hasRowSelection.value && isRowSelected(rowId)) {
clearCellSelection();
void prefetchCopyStatements();
return;
}
@@ -5192,6 +5193,9 @@ function onRowContext(rowId: number, rowIndex: number) {
contextHeaderColumn.value = null;
contextHeaderColumnIndex.value = null;
contextCell.value = { rowId, rowIndex, col: -1 };
if (hasRowSelection.value && isRowSelected(rowId)) {
clearCellSelection();
}
if (!isRowSelected(rowId)) {
clearCellSelection();
selectedRowIds.value = new Set([rowId]);
@@ -516,7 +516,9 @@ defineExpose({ focusSearch, refreshData, handleModRTarget });
variant="ghost"
size="icon"
class="ml-auto h-6 w-7 shrink-0 text-foreground hover:bg-accent"
:class="{ 'bg-accent text-foreground': dataGridRef?.nullColumnsHidden }"
:class="{
'bg-accent text-foreground': dataGridRef?.nullColumnsHidden || dataGridRef?.multiRowTranspose,
}"
:title="t('grid.viewOptions')"
:aria-label="t('grid.viewOptions')"
>
@@ -532,6 +534,32 @@ defineExpose({ focusSearch, refreshData, handleModRTarget });
<div class="border-b bg-muted/40 px-3 py-2">
<div class="text-xs font-semibold">{{ t("grid.viewOptions") }}</div>
</div>
<LightTooltip
:text="t('grid.transposeMultiRowHint')"
side="left"
:side-offset="6"
:delay="0"
:open-on-focus="false"
>
<label
class="flex cursor-pointer items-center justify-between gap-3 px-3 py-2 text-xs hover:bg-accent"
>
<span class="min-w-0 flex items-center gap-1.5 font-medium">
{{ t("grid.transposeMultiRowToggle") }}
<span class="text-muted-foreground">
{{
dataGridRef?.multiRowTranspose ? t("grid.transposeMultiRow") : t("grid.transposeSingleRow")
}}
</span>
</span>
<Switch
size="sm"
:model-value="!!dataGridRef?.multiRowTranspose"
:aria-label="t('grid.transposeMultiRow')"
@update:model-value="(value: boolean) => dataGridRef?.setMultiRowTranspose(value)"
/>
</label>
</LightTooltip>
<label
class="flex cursor-pointer items-center gap-2 px-3 py-2 text-xs hover:bg-accent"
:class="{ 'cursor-not-allowed opacity-60': !dataGridRef?.canToggleAllNullColumns }"