fix(grid): restore long cell values in the detail editor
This commit is contained in:
1 parent
15d451d43a
commit
a216e0938e
6 files changed
+177
-7
No files matched your search
@@ -5786,7 +5786,16 @@ watch(valueEditorContainer, async (el) => {
|
||||
fontSize: editorFontSize,
|
||||
fontFamily: detailEditorFontFamily,
|
||||
});
|
||||
await valueDetailEditor.create(el, detailEditValue.value, activeCellDetail.value?.type);
|
||||
const editor = valueDetailEditor;
|
||||
await editor.create(el, detailEditValue.value, activeCellDetail.value?.type);
|
||||
// The editor initializes asynchronously (theme loading can yield here), so
|
||||
// detailEditValue may have changed before CodeMirror owns the document.
|
||||
// Reconcile the latest value after create and ignore an editor replaced by
|
||||
// a fast tab unmount/remount.
|
||||
if (valueDetailEditor !== editor) return;
|
||||
if (editor.getValue() !== detailEditValue.value) {
|
||||
editor.setValue(detailEditValue.value, activeCellDetail.value?.type);
|
||||
}
|
||||
} else if (!el && valueDetailEditor) {
|
||||
valueDetailEditor.destroy();
|
||||
valueDetailEditor = null;
|
||||
@@ -5809,7 +5818,7 @@ const detailEdit = useDataGridCellDetailEdit({
|
||||
restoreCellValue,
|
||||
syncEditor: (value, columnType) => {
|
||||
const editor = getDetailEditor();
|
||||
if (editor) editor.setValue(value, columnType);
|
||||
if (editor && editor.getValue() !== value) editor.setValue(value, columnType);
|
||||
},
|
||||
refreshDetail: () => {
|
||||
detailCell.value = detailCell.value ? { ...detailCell.value } : null;
|
||||
|
||||
@@ -1392,6 +1392,14 @@ describe("cell detail surfaces", () => {
|
||||
}
|
||||
expect(dataGridSource).not.toContain("activeCellDetailTabsGridClass");
|
||||
|
||||
const valueEditorLifecycleStart = dataGridSource.indexOf("watch(valueEditorContainer");
|
||||
const valueEditorLifecycleEnd = dataGridSource.indexOf("const detailEdit = useDataGridCellDetailEdit", valueEditorLifecycleStart);
|
||||
const valueEditorLifecycle = dataGridSource.slice(valueEditorLifecycleStart, valueEditorLifecycleEnd);
|
||||
expect(valueEditorLifecycle).toContain("const editor = valueDetailEditor;");
|
||||
expect(valueEditorLifecycle).toContain("if (valueDetailEditor !== editor) return;");
|
||||
expect(valueEditorLifecycle).toContain("if (editor.getValue() !== detailEditValue.value)");
|
||||
expect(valueEditorLifecycle).toContain("editor.setValue(detailEditValue.value, activeCellDetail.value?.type);");
|
||||
|
||||
const valueEditorStart = dataGridSource.indexOf("<TabsContent v-if=\"activeCellDetailTabs.includes('valueEditor')\"");
|
||||
const valueEditorEnd = dataGridSource.indexOf("</TabsContent>", valueEditorStart);
|
||||
const valueEditor = dataGridSource.slice(valueEditorStart, valueEditorEnd);
|
||||
|
||||
Reference in new issue
Block a user