From b3f6c45bc1aceea7cee53c553551c247fc9610f6 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Sat, 23 May 2026 18:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(DataGrid):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=AD=9B=E9=80=89=E5=AD=97=E6=AE=B5=E5=90=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=AE=8C=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 扩展筛选与排序字段下拉宽度 - 为字段选项补充完整 title 与省略显示 - 补充字段名完整展示回归测试 Refs #481 --- .../src/components/DataGrid.layout.test.tsx | 11 ++++ frontend/src/components/DataGrid.tsx | 50 +++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/DataGrid.layout.test.tsx b/frontend/src/components/DataGrid.layout.test.tsx index 5e301bc..e0755fb 100644 --- a/frontend/src/components/DataGrid.layout.test.tsx +++ b/frontend/src/components/DataGrid.layout.test.tsx @@ -3,6 +3,7 @@ import { renderToStaticMarkup } from 'react-dom/server'; import { describe, expect, it, vi } from 'vitest'; import DataGrid, { + buildGridFieldSelectOptions, formatCellDisplayText, resolveContextMenuFieldName, resolveDefaultGridFilterOperator, @@ -140,6 +141,16 @@ describe('DataGrid layout', () => { })).toBe('STARTS_WITH'); }); + it('keeps full field names in filter field select options', () => { + const [option] = buildGridFieldSelectOptions(['mes_manufacture_order_really_long_column_name']); + + expect(option).toEqual({ + value: 'mes_manufacture_order_really_long_column_name', + label: 'mes_manufacture_order_really_long_column_name', + title: 'mes_manufacture_order_really_long_column_name', + }); + }); + it('renders a DDL action for table data pages only', () => { const tableMarkup = renderToStaticMarkup( ( + (columnNames || []).map((columnName) => { + const text = String(columnName || ''); + return { + value: text, + label: text, + title: text, + }; + }) +); + +const renderGridFieldSelectOption = (option: { label?: React.ReactNode; value?: unknown; title?: unknown }) => { + const text = String(option?.title ?? option?.label ?? option?.value ?? ''); + return ( + + {text} + + ); +}; + type NormalizeCommitCellValue = (columnName: string, value: any, mode: 'insert' | 'update') => any; type DataGridCommitChangeSet = { @@ -2786,6 +2819,11 @@ const DataGrid: React.FC = ({ })); }, [allTableColumnNames, displayColumnNames, quickWhereDraft, dbType, darkMode]); + const gridFieldSelectOptions = useMemo( + () => buildGridFieldSelectOptions(displayColumnNames), + [displayColumnNames], + ); + useEffect(() => { if (!showFilter) { return; @@ -6363,12 +6401,14 @@ const DataGrid: React.FC = ({ disabled={condIndex === 0} /> { const next = [...sortInfo]; @@ -6458,9 +6498,11 @@ const DataGrid: React.FC = ({ }} options={displayColumnNames .filter(c => c === s.columnKey || !sortInfo.some(si => si.columnKey === c)) - .map(c => ({ value: c, label: c }))} + .map(c => ({ value: c, label: c, title: c }))} showSearch optionFilterProp="label" + optionRender={renderGridFieldSelectOption} + popupMatchSelectWidth={FILTER_FIELD_POPUP_WIDTH} filterOption={(input, option) => String(option?.label ?? '') .toLowerCase()