fix(grid): copy cells containing double quotes verbatim

This commit is contained in:
弈秋 authored and GitHub committed 2026-09-23 14:43:06 +08:00
1 parent bd32919542
commit 6471e37e5f
6 files changed
+97 -19

No files matched your search

@@ -726,7 +726,7 @@ describe("useDataGridExport prepared row statements", () => {
]);
});
it("uses escaped TSV for a multi-cell smart copy without relying on clipboard metadata", async () => {
it("uses TSV (quotes only for separator/newline) for a multi-cell smart copy without relying on clipboard metadata", async () => {
const rows = [
[1, '{"msg":"success"}'],
[2, "inside\ttab\nnext line"],
@@ -737,7 +737,9 @@ describe("useDataGridExport prepared row statements", () => {
columns: ["id", "name"],
rows,
};
const text = '1\t"{""msg"":""success""}"\n2\t"inside\ttab\nnext line"';
// A value containing only double quotes is copied verbatim (#10087); a value
// containing a tab/newline is still quoted so the TSV shape survives.
const text = '1\t{"msg":"success"}\n2\t"inside\ttab\nnext line"';
vi.mocked(extractDataGridSelection).mockResolvedValueOnce({ text, mimeType: "text/tab-separated-values", fileExtension: "tsv", rowCount: 2, columnCount: 2 });
const state = createExportState(editableTable, ["id", "name"], matrix, undefined, undefined, rows);