Skip to content

Commit 2fd932a

Browse files
[DataObject][AdvancedManyToManyObjectRelation] Reordering Advanced Objects Freezes UI (#3375)
* added the row virtualizer into the ManyToManyRelationGrid * fixed styles * Automatic frontend build --------- Co-authored-by: ValeriaMaltseva <11871778+ValeriaMaltseva@users.noreply.github.com>
1 parent 3d63c5d commit 2fd932a

750 files changed

Lines changed: 30075 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/js/src/core/components/grid/grid-cell/grid-row.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface GridRowProps {
3232
onFocusCell?: (cell: GridCellReference) => void
3333
contextMenu?: ListGridContextMenuComponents
3434
onRowDoubleClick?: GridProps['onRowDoubleClick']
35+
enableRowVirtualizer: boolean
3536
enableColumnVirtualizer: boolean
3637
size?: GridProps['size']
3738
rowStyle?: CSSProperties
@@ -42,7 +43,7 @@ export interface GridRowProps {
4243
virtualPaddingRight?: number
4344
}
4445

45-
const GridRow = ({ row, isSelected, modifiedCells, rowStyle, virtualColumns, virtualPaddingLeft, virtualPaddingRight, enableColumnVirtualizer, ...props }: GridRowProps): React.JSX.Element => {
46+
const GridRow = ({ row, isSelected, modifiedCells, rowStyle, virtualColumns, virtualPaddingLeft, virtualPaddingRight, enableColumnVirtualizer, enableRowVirtualizer, ...props }: GridRowProps): React.JSX.Element => {
4647
const { setNodeRef, transform, transition, isDragging, attributes, listeners } = useSortable({
4748
id: row.id
4849
})
@@ -134,20 +135,26 @@ const GridRow = ({ row, isSelected, modifiedCells, rowStyle, virtualColumns, vir
134135
}
135136
>
136137
{visibleCells?.map((cell) => {
138+
const isAutoWidth = cell.column.columnDef.meta?.autoWidth === true
139+
const columnSize = cell.column.getSize()
140+
141+
const tdStyle: CSSProperties = isAutoWidth
142+
? {
143+
width: 'auto',
144+
minWidth: columnSize,
145+
...(enableRowVirtualizer ? { flexShrink: 1, flexGrow: 1 } : {})
146+
}
147+
: {
148+
width: columnSize,
149+
maxWidth: columnSize,
150+
...(enableRowVirtualizer ? { flexShrink: 0 } : {})
151+
}
152+
137153
return (
138154
<td
139155
className='ant-table-cell'
140156
key={ cell.id }
141-
style={ cell.column.columnDef.meta?.autoWidth === true
142-
? {
143-
width: 'auto',
144-
minWidth: cell.column.getSize()
145-
}
146-
: {
147-
width: cell.column.getSize(),
148-
maxWidth: cell.column.getSize()
149-
}
150-
}
157+
style={ tdStyle }
151158
>
152159
{cell.column.id === 'drag-handle'
153160
? renderRowReorderButton()

assets/js/src/core/components/grid/grid.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ export const Grid = ({
390390
columns={ columns }
391391
contextMenu={ props.contextMenu }
392392
enableColumnVirtualizer={ isEnableColumnVirtualizer }
393+
enableRowVirtualizer={ isEnableRowVirtualizer }
393394
isSelected={ row.getIsSelected() }
394395
key={ row.id }
395396
measureElement={ measureElement }
@@ -461,11 +462,13 @@ export const Grid = ({
461462
header.column.columnDef.meta?.autoWidth === true && !header.column.getIsResizing()
462463
? {
463464
width: 'auto',
464-
minWidth: header.column.getSize()
465+
minWidth: header.column.getSize(),
466+
...(isEnableRowVirtualizer ? { flexShrink: 1, flexGrow: 1 } : {})
465467
}
466468
: {
467469
width: header.column.getSize(),
468-
maxWidth: header.column.getSize()
470+
maxWidth: header.column.getSize(),
471+
...(isEnableRowVirtualizer ? { flexShrink: 0 } : {})
469472
}
470473
}
471474
>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* This source file is available under the terms of the
3+
* Pimcore Open Core License (POCL)
4+
* Full copyright and license information is available in
5+
* LICENSE.md which is distributed with this source code.
6+
*
7+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
8+
* @license Pimcore Open Core License (POCL)
9+
*/
10+
11+
import { createStyles } from 'antd-style'
12+
13+
export interface UseStylesProps {
14+
height: string | null
15+
}
16+
17+
export const useStyles = createStyles(({ css }, { height }: UseStylesProps) => {
18+
const maxHeight = height ?? '500px'
19+
20+
return {
21+
grid: css`
22+
position: relative;
23+
width: 100%;
24+
max-height: ${maxHeight};
25+
overflow: auto;
26+
27+
.ant-table-content table {
28+
width: calc(100% - 2px) !important;
29+
}
30+
`
31+
}
32+
})

assets/js/src/core/components/many-to-many-relation/grid.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { toCssDimension } from '@Pimcore/utils/css'
2222
import { Content } from '@Pimcore/components/content/content'
2323
import { type OnUpdateCellDataEvent } from '@Pimcore/types/components/types'
2424
import { useColumns } from './hooks/use-columns'
25+
import { useStyles } from './grid.styles'
2526

2627
export interface ManyToManyRelationGridProps {
2728
value?: ManyToManyRelationValue | null
@@ -45,6 +46,7 @@ export const ManyToManyRelationGrid = forwardRef(function ManyToManyRelationGrid
4546
const { getStateClasses } = useDroppable()
4647
const { mapToLegacyElementType } = useElementHelper()
4748
const { columns } = useColumns(props)
49+
const { styles } = useStyles({ height: toCssDimension(props.height) ?? null })
4850
const [data, setData] = useState(getDataArray())
4951

5052
useEffect(() => {
@@ -87,19 +89,20 @@ export const ManyToManyRelationGrid = forwardRef(function ManyToManyRelationGrid
8789

8890
const content = useMemo(() => (
8991
<Content
92+
overflow={ { x: 'hidden', y: 'hidden' } }
9093
style={ {
91-
width: toCssDimension(props.width),
92-
height: toCssDimension(props.height)
94+
width: toCssDimension(props.width)
9395
} }
9496
>
9597
<div style={ { maxWidth: 'calc(100% - 2px)' } }>
9698
<Grid
9799
autoWidth
98-
className={ props.className }
100+
className={ cn(styles.grid, props.className) }
99101
columns={ columns }
100102
data={ data }
101103
disabled={ props.disabled === true || props.inherited === true }
102104
enableRowDrag={ props.enableRowDrag }
105+
enableRowVirtualizer
103106
handleDragEnd={ handleDragEnd }
104107
onUpdateCellData={ props.onUpdateCellData }
105108
resizable

public/build/1f5ef8a5-82fc-415c-9cf8-e238bb042f2c/documentEditorIframe.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/1f5ef8a5-82fc-415c-9cf8-e238bb042f2c/entrypoints.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/1f5ef8a5-82fc-415c-9cf8-e238bb042f2c/exposeRemote.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/1f5ef8a5-82fc-415c-9cf8-e238bb042f2c/main.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/1f5ef8a5-82fc-415c-9cf8-e238bb042f2c/manifest.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/1f5ef8a5-82fc-415c-9cf8-e238bb042f2c/mf-manifest.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)