11 files changed
+43
No files matched your search
@@ -12092,6 +12092,7 @@ function currentGridContextMenuItems(): ContextMenuItem[] {
|
||||
:match-count="searchMatches.length"
|
||||
:current-match-index="currentMatchIndex"
|
||||
:has-deferred-search-text="!!deferredClientSearchText"
|
||||
:values-truncated="(props.result.large_value_cells?.length ?? 0) > 0"
|
||||
@keydown="onSearchKeydown"
|
||||
@navigate="navigateMatch"
|
||||
@close="closeSearch"
|
||||
|
||||
@@ -12,6 +12,8 @@ const props = defineProps<{
|
||||
matchCount: number;
|
||||
currentMatchIndex: number;
|
||||
hasDeferredSearchText: boolean;
|
||||
/** 结果里含被截断显示的长值(large_value_cells),搜索只覆盖显示文本。 */
|
||||
valuesTruncated?: boolean;
|
||||
}>();
|
||||
|
||||
const searchText = defineModel<string>("text", { default: "" });
|
||||
@@ -72,6 +74,11 @@ defineExpose({
|
||||
<span>{{ suggestion }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 截断标记:表格预览对长文本/JSON 值做服务端截断,客户端搜索只能覆盖
|
||||
显示前缀,匹配数可能少于 SQL 查询(#7279)。 -->
|
||||
<span v-if="props.valuesTruncated && (props.matchCount > 0 || props.hasDeferredSearchText)" data-grid-search-truncated-hint class="text-xs text-amber-600 dark:text-amber-400 shrink-0 cursor-help" :title="t('grid.searchTruncatedValuesHint')" :aria-label="t('grid.searchTruncatedValuesHint')"
|
||||
>≈</span
|
||||
>
|
||||
<span v-if="props.matchCount > 0" class="text-xs text-muted-foreground shrink-0">{{ props.currentMatchIndex + 1 }}/{{ props.matchCount }}</span>
|
||||
<span v-else-if="props.hasDeferredSearchText" class="text-xs text-muted-foreground shrink-0">0</span>
|
||||
<button
|
||||
|
||||
@@ -321,6 +321,33 @@ describe("DataGrid context menu target lifecycle", () => {
|
||||
expect(contextMenuLabels()).toContain("Filter");
|
||||
});
|
||||
|
||||
async function openGridSearchAndType(host: HTMLElement, query: string) {
|
||||
await settle();
|
||||
const gridRoot = host.querySelector<HTMLElement>("[data-grid-root]");
|
||||
if (!gridRoot) throw new Error("Grid root not found");
|
||||
gridRoot.dispatchEvent(new KeyboardEvent("keydown", { key: "f", ctrlKey: true, bubbles: true, cancelable: true }));
|
||||
await settle();
|
||||
const input = host.querySelector<HTMLInputElement>("input[type=search]");
|
||||
if (!input) throw new Error("Search input not found");
|
||||
input.value = query;
|
||||
input.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
await settle();
|
||||
// useDataGridSearch 防抖 150ms,等待 deferredSearchText 生效
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
}
|
||||
|
||||
it("marks the search overlay when truncated large values may hide matches (issue #7279)", async () => {
|
||||
const { host } = mountGrid(largeValueResult(1, "preview"));
|
||||
await openGridSearchAndType(host, "prev");
|
||||
expect(host.querySelector("[data-grid-search-truncated-hint]")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("does not show the truncation hint for fully loaded values", async () => {
|
||||
const { host } = mountGrid(hydratedResult(1, "preview"));
|
||||
await openGridSearchAndType(host, "prev");
|
||||
expect(host.querySelector("[data-grid-search-truncated-hint]")).toBeNull();
|
||||
});
|
||||
|
||||
it("offers toolbar-equivalent refresh in the cell context menu (issue #7273)", async () => {
|
||||
const onReload = vi.fn();
|
||||
const { host } = mountGrid(hydratedResult(1, "value"), onReload);
|
||||
|
||||
Reference in new issue
Block a user