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

fix(VDataTable): max-width doesn work properly, new prop to wrap text when use maxWidth #18961

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/vuetify/src/components/VDataTable/VDataTable.sass
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
&.v-data-table-column--no-padding
padding: 0 8px

&.v-data-table-column--nowrap
text-overflow: ellipsis
text-wrap: nowrap
overflow: hidden

& .v-data-table-header__content
display: contents

> th
align-items: center

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const VDataTableColumn = defineFunctionalComponent({
noPadding: Boolean,
tag: String,
width: [Number, String],
maxWidth: [Number, String],
nowrap: Boolean,
}, (props, { slots }) => {
const Tag = props.tag ?? 'td'
return (
Expand All @@ -26,12 +28,14 @@ export const VDataTableColumn = defineFunctionalComponent({
'v-data-table-column--fixed': props.fixed,
'v-data-table-column--last-fixed': props.lastFixed,
'v-data-table-column--no-padding': props.noPadding,
'v-data-table-column--nowrap': props.nowrap,
},
`v-data-table-column--align-${props.align}`,
]}
style={{
height: convertToUnit(props.height),
width: convertToUnit(props.width),
maxWidth: convertToUnit(props.maxWidth),
left: convertToUnit(props.fixedOffset || null),
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
style={{
width: convertToUnit(column.width),
minWidth: convertToUnit(column.minWidth),
maxWidth: convertToUnit(column.maxWidth),
...getFixedStyles(column, y),
}}
colspan={ column.colspan }
rowspan={ column.rowspan }
onClick={ column.sortable ? () => toggleSort(column) : undefined }
fixed={ column.fixed }
nowrap={ column.nowrap }
lastFixed={ column.lastFixed }
noPadding={ noPadding }
{ ...headerProps }
Expand Down
2 changes: 2 additions & 0 deletions packages/vuetify/src/components/VDataTable/VDataTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export const VDataTableRow = genericComponent<new <T>(
lastFixed={ column.lastFixed }
noPadding={ column.key === 'data-table-select' || column.key === 'data-table-expand' }
width={ column.width }
maxWidth={ column.maxWidth }
nowrap={ column.nowrap }
{ ...cellProps }
{ ...columnCellProps }
>
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VDataTable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type DataTableHeader<T = Record<string, any>> = {
width?: number | string
minWidth?: string
maxWidth?: string
nowrap?: boolean

headerProps?: Record<string, any>
cellProps?: HeaderCellProps
Expand Down
Loading