🐛 fix(ui): 修复数据表按钮与侧栏滚动条显示

- 修复 v2 分页“统计总数”按钮被压缩为图标宽度的问题

- 首次打开时隐藏树主体横向溢出,保留独立横向滚动条占位

- 将自定义字段显示里的全局隐藏列文案改为多语言翻译

- 增加数据表按钮和侧栏横向滚动条布局回归断言
This commit is contained in:
Syngnat
2026-07-08 17:37:21 +08:00
parent da895ea502
commit 22fab86010
4 changed files with 63 additions and 10 deletions

View File

@@ -996,6 +996,38 @@ describe('DataGrid layout', () => {
}
});
it('keeps the v2 pagination total-count action readable instead of icon-button width', () => {
const css = readV2ThemeCss();
const markup = renderToStaticMarkup(
<DataGridPaginationBar
isV2Ui
pagination={{
current: 1,
pageSize: 500,
total: 500,
totalKnown: false,
}}
paginationV2SummaryText="当前 500 条 / 未统计总数"
paginationSummaryText="当前 500 条 / 未统计总数"
paginationControlTotal={500}
paginationTotalPages={1}
paginationPageText="第 1 页"
paginationPageSizeOptions={['500']}
showKnownPageCount={false}
manualTotalCountAvailable
onPageChange={() => {}}
onPageSizeChange={() => {}}
onV2PageStep={() => {}}
onToggleTotalCount={() => {}}
/>,
);
expect(markup).toContain('data-grid-pagination-total-count="true"');
expect(markup).toContain('统计总数');
expect(css).toMatch(/\[data-grid-pagination-total-count="true"\]\.ant-btn \{[\s\S]*?width: auto !important;[\s\S]*?min-width: max-content !important;[\s\S]*?white-space: nowrap;/);
expect(css).toMatch(/\[data-grid-pagination-total-count="true"\]\.ant-btn \.ant-btn-icon \{[\s\S]*?margin-inline-end: 3px !important;/);
});
it('hides current-page find in JSON and text record views', () => {
const source = readDataGridSource();

View File

@@ -34,12 +34,7 @@ export interface DataGridColumnInfoPopoverContentProps {
onResetHidden: () => void;
}
const GLOBAL_HIDDEN_LABEL = 'Global hidden columns';
const GLOBAL_HIDDEN_HELP = 'Column names listed here are hidden in query results wherever they appear. Separate names with comma or newline.';
const GLOBAL_HIDDEN_PLACEHOLDER = 'id\ncreated_by\nupdated_at';
const GLOBAL_HIDDEN_SAVE = 'Apply global';
const GLOBAL_HIDDEN_ADD_LOCAL = 'Add current hidden';
const GLOBAL_HIDDEN_CLEAR = 'Clear global';
const DataGridColumnInfoPopoverContent: React.FC<DataGridColumnInfoPopoverContentProps> = ({
darkMode,
@@ -132,8 +127,12 @@ const DataGridColumnInfoPopoverContent: React.FC<DataGridColumnInfoPopoverConten
</div>
<div style={{ height: 1, backgroundColor: darkMode ? '#424242' : '#f0f0f0', margin: '4px 0' }} />
<div style={{ fontWeight: 600, fontSize: 13, color: darkMode ? '#ddd' : '#666' }}>{GLOBAL_HIDDEN_LABEL}</div>
<div style={{ fontSize: 12, lineHeight: 1.5, color: darkMode ? '#aaa' : '#888' }}>{GLOBAL_HIDDEN_HELP}</div>
<div style={{ fontWeight: 600, fontSize: 13, color: darkMode ? '#ddd' : '#666' }}>
{translate('data_grid.column_settings.global_hidden_columns')}
</div>
<div style={{ fontSize: 12, lineHeight: 1.5, color: darkMode ? '#aaa' : '#888' }}>
{translate('data_grid.column_settings.global_hidden_columns_help')}
</div>
<Input.TextArea
autoSize={{ minRows: 2, maxRows: 4 }}
placeholder={GLOBAL_HIDDEN_PLACEHOLDER}
@@ -141,10 +140,16 @@ const DataGridColumnInfoPopoverContent: React.FC<DataGridColumnInfoPopoverConten
onChange={(event) => setGlobalHiddenText(event.target.value)}
/>
<div style={{ display: 'flex', gap: 8 }}>
<Button size="small" style={{ flex: 1 }} onClick={saveGlobalHiddenText}>{GLOBAL_HIDDEN_SAVE}</Button>
<Button size="small" style={{ flex: 1 }} disabled={localHiddenColumns.length === 0} onClick={addCurrentHiddenColumnsToGlobal}>{GLOBAL_HIDDEN_ADD_LOCAL}</Button>
<Button size="small" style={{ flex: 1 }} onClick={saveGlobalHiddenText}>
{translate('data_grid.column_settings.global_hidden_columns_apply')}
</Button>
<Button size="small" style={{ flex: 1 }} disabled={localHiddenColumns.length === 0} onClick={addCurrentHiddenColumnsToGlobal}>
{translate('data_grid.column_settings.global_hidden_columns_add_current')}
</Button>
</div>
<Button size="small" danger disabled={!globalHiddenText.trim()} onClick={clearGlobalHiddenColumns}>{GLOBAL_HIDDEN_CLEAR}</Button>
<Button size="small" danger disabled={!globalHiddenText.trim()} onClick={clearGlobalHiddenColumns}>
{translate('data_grid.column_settings.global_hidden_columns_clear')}
</Button>
<div style={{ height: 1, backgroundColor: darkMode ? '#424242' : '#f0f0f0', margin: '4px 0' }} />
<Checkbox checked={enableColumnOrderMemory} onChange={(e) => onEnableColumnOrderMemoryChange(e.target.checked)}>

View File

@@ -1232,6 +1232,7 @@ describe('Sidebar locate toolbar', () => {
expect(css).not.toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list-holder-inner \{[^}]*width: max-content;/s);
expect(css).not.toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list \{[^}]*position: static !important;/s);
expect(css).toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list-holder \{[^}]*height: calc\(100% - var\(--gn-v2-tree-horizontal-scroll-reserve\)\);[^}]*max-height: calc\(100% - var\(--gn-v2-tree-horizontal-scroll-reserve\)\) !important;/s);
expect(css).toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list-holder \{[^}]*overflow-x: hidden !important;/s);
expect(css).not.toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list-holder \{[^}]*overflow-x: auto !important;/s);
expect(css).not.toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list-holder \{[^}]*padding-bottom: var\(--gn-v2-tree-horizontal-scroll-reserve\);/s);
expect(css).toMatch(/\.gn-v2-explorer-tree-shell \.ant-tree-list-scrollbar-horizontal \{[^}]*height: 12px !important;[^}]*bottom: 0 !important;/s);

View File

@@ -2635,6 +2635,7 @@ body[data-ui-version="v2"] .gn-v2-explorer-tree-shell .ant-tree-list-holder {
box-sizing: border-box;
height: calc(100% - var(--gn-v2-tree-horizontal-scroll-reserve));
max-height: calc(100% - var(--gn-v2-tree-horizontal-scroll-reserve)) !important;
overflow-x: hidden !important;
scrollbar-width: thin;
}
@@ -4714,6 +4715,20 @@ body[data-ui-version="v2"] .gn-v2-data-grid-pagination-wrap .ant-btn {
vertical-align: top;
}
body[data-ui-version="v2"] .gn-v2-data-grid-pagination-wrap [data-grid-pagination-total-count="true"].ant-btn {
width: auto !important;
min-width: max-content !important;
max-width: none !important;
flex: 0 0 auto;
gap: 4px;
padding: 0 8px !important;
white-space: nowrap;
}
body[data-ui-version="v2"] .gn-v2-data-grid-pagination-wrap [data-grid-pagination-total-count="true"].ant-btn .ant-btn-icon {
margin-inline-end: 3px !important;
}
body[data-ui-version="v2"] .gn-v2-data-grid-page-find .ant-btn:hover,
body[data-ui-version="v2"] .gn-v2-data-grid-column-quick-find .ant-btn:hover,
body[data-ui-version="v2"] .gn-v2-data-grid-pagination-wrap .ant-btn:hover {