fix: issue where right-fixed column does not align to the right when there are fewer columns (#5690)

This commit is contained in:
Katherine 2024-11-20 15:44:16 +08:00 committed by GitHub
parent 64da031cef
commit ff36b35352
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 11 deletions

View File

@ -195,26 +195,26 @@ export const tableBlockSettings = new SchemaSettings({
const fieldSchema = useFieldSchema();
const { t } = useTranslation();
const { dn } = useDesignable();
const schema = fieldSchema.reduceProperties((_, s) => {
if (s['x-component'] === 'TableV2') {
return s;
}
}, null);
return {
title: t('Table size'),
value: field.componentProps?.size || 'middle',
value: schema?.['x-component-props']?.size || 'middle',
options: [
{ label: t('Large'), value: 'large' },
{ label: t('Middle'), value: 'middle' },
{ label: t('Small'), value: 'small' },
],
onChange: (size) => {
const schema = fieldSchema.reduceProperties((_, s) => {
if (s['x-component'] === 'TableV2') {
return s;
}
}, null);
schema['x-component-props'] = schema['x-component-props'] || {};
schema['x-component-props']['size'] = size;
dn.emit('patch', {
schema: {
['x-uid']: schema['x-uid'],
'x-decorator-props': schema['x-component-props'],
'x-component-props': schema['x-component-props'],
},
});
},

View File

@ -178,7 +178,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
return columns;
}
const res = [
...adjustColumnOrder(columns),
...columns,
{
title: render(),
dataIndex: 'TABLE_COLUMN_INITIALIZER',
@ -186,7 +186,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
render: designable
? () => <div style={{ width: '100%', minWidth: '180px' }} className="nb-column-initializer" />
: null,
fixed: 'right',
fixed: designable ? 'right' : 'none',
},
];
@ -224,7 +224,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
});
}
return res;
return adjustColumnOrder(res);
}, [columns, exists, field, render, props.showDel, designable]);
return tableColumns;
@ -588,7 +588,6 @@ const InternalNocoBaseTable = React.memo(
field,
...others
} = props;
return (
<div
className={cx(
@ -609,6 +608,12 @@ const InternalNocoBaseTable = React.memo(
.ant-table-body {
min-height: ${tableHeight}px;
}
.ant-table-small .ant-table-cell {
padding: 8px 16px;
}
.ant-table-middle .ant-table-cell {
padding: 12px 16px;
}
}
}
}