Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to wrap table's column header #9565

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions frontend/src/Editor/Components/Table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function Table({
maxRowHeightValue,
borderColor,
isMaxRowHeightAuto,
columnHeaderWrap,
} = loadPropertiesAndStyles(properties, styles, darkMode, component);
const updatedDataReference = useRef([]);
const preSelectRow = useRef(false);
Expand Down Expand Up @@ -1328,11 +1329,14 @@ export function Table({
data-cy={`column-header-${String(column.exportValue)
.toLowerCase()
.replace(/\s+/g, '-')}`}
className={`header-text ${
column.id === 'selection' &&
column.columnType === 'selector' &&
'selector-column'
}`}
className={cx('header-text', {
'selector-column':
column.id === 'selection' && column.columnType === 'selector',
'text-truncate':
resolveReferences(columnHeaderWrap, currentState) === 'fixed',
'wrap-wrapper':
resolveReferences(columnHeaderWrap, currentState) === 'wrap',
})}
>
{column.render('Header')}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default function loadPropertiesAndStyles(properties, styles, darkMode, co
const selectRowOnCellEdit = properties?.selectRowOnCellEdit ?? true;
const contentWrapProperty = styles?.contentWrap ?? true;
const borderColor = styles?.borderColor ?? 'var(--borders-weak-disabled)';
const columnHeaderWrap = styles?.columnHeaderWrap ?? 'fixed';

return {
color,
Expand Down Expand Up @@ -120,5 +121,6 @@ export default function loadPropertiesAndStyles(properties, styles, darkMode, co
contentWrapProperty,
boxShadow,
borderColor,
columnHeaderWrap,
};
}
11 changes: 11 additions & 0 deletions frontend/src/Editor/WidgetManager/widgetConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@ export const widgets = [
},
accordian: 'Data',
},
columnHeaderWrap: {
type: 'switch',
displayName: 'Column header',
validation: { schema: { type: 'string' } },
accordian: 'Data',
options: [
{ displayName: 'Fixed', value: 'fixed' },
{ displayName: 'Wrap', value: 'wrap' },
],
},
tableType: {
type: 'select',
displayName: 'Row style',
Expand Down Expand Up @@ -618,6 +628,7 @@ export const widgets = [
events: [],
styles: {
textColor: { value: '#000' },
columnHeaderWrap: { value: 'fixed' },
actionButtonRadius: { value: '0' },
cellSize: { value: 'regular' },
borderRadius: { value: '8' },
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/_styles/table-component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
}

.tr {
height: 32px;

.th {
.thead-editable-icon-header-text-wrapper {
max-width: 100%;
Expand All @@ -82,9 +80,7 @@
}

.header-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
}
}

Expand Down