Skip to content

Commit cb99e78

Browse files
feat(AnalyticalTable): support resize on whole column (#607)
closes #580
1 parent 80797f3 commit cb99e78

File tree

4 files changed

+439
-487
lines changed

4 files changed

+439
-487
lines changed

packages/main/src/components/AnalyticalTable/AnayticalTable.jss.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const styles = {
1616
},
1717
tableHeaderRow: {
1818
height: CssSizeVariables.sapWcrAnalyticalTableRowHeight,
19-
position: 'relative',
2019
display: 'inline-flex'
2120
},
2221
th: {

packages/main/src/components/AnalyticalTable/ColumnHeader/index.tsx

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,17 @@ const styles = {
8181
},
8282
resizer: {
8383
display: 'inline-block',
84-
width: '16px',
84+
width: '3px',
8585
height: '100%',
8686
position: 'absolute',
87-
right: 0,
87+
bottom: 0,
8888
top: 0,
89-
transform: 'translateX(50%)',
90-
zIndex: 1
89+
transform: 'translateX(-50%)',
90+
zIndex: 1,
91+
cursor: 'col-resize',
92+
'&:hover, &:active': {
93+
backgroundColor: ThemingParameters.sapContent_DragAndDropActiveColor
94+
}
9195
}
9296
};
9397

@@ -118,11 +122,6 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
118122
} = props;
119123

120124
const isFiltered = column.filterValue && column.filterValue.length > 0;
121-
const sortingIcon = column.isSorted ? (
122-
<Icon name={column.isSortedDesc ? 'sort-descending' : 'sort-ascending'} />
123-
) : null;
124-
const filterIcon = isFiltered ? <Icon name="filter" /> : null;
125-
const groupingIcon = column.isGrouped ? <Icon name="group-2" /> : null;
126125

127126
const textStyle = useMemo(() => {
128127
let margin = 0;
@@ -148,22 +147,13 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
148147
}, [column.isSorted, column.isGrouped, isFiltered]);
149148

150149
const hasPopover = column.canGroupBy || column.canSort || column.canFilter;
151-
const innerStyle: CSSProperties = useMemo(() => {
152-
const modifiedStyles: CSSProperties = {
153-
cursor: hasPopover ? 'pointer' : 'auto'
154-
};
155-
if (dragOver) {
156-
modifiedStyles.borderLeft = `3px solid ${ThemingParameters.sapSelectedColor}`;
157-
}
158-
return modifiedStyles;
159-
}, [dragOver, hasPopover]);
160150

161151
const popoverRef = useRef<Ui5PopoverDomRef>(null);
162152

163153
const onOpenPopover = useCallback(
164154
(e) => {
165155
if (popoverRef.current && hasPopover) {
166-
popoverRef.current.openBy(e.target);
156+
popoverRef.current.openBy(e.currentTarget);
167157
}
168158
},
169159
[popoverRef, hasPopover]
@@ -172,38 +162,50 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
172162
if (!column) return null;
173163

174164
return (
175-
<div
176-
id={id}
177-
className={className}
178-
style={style}
179-
role={role}
180-
draggable={isDraggable}
181-
onDragEnter={onDragEnter}
182-
onDragOver={onDragOver}
183-
onDragStart={onDragStart}
184-
onDrop={onDrop}
185-
onDragEnd={onDragEnd}
186-
data-column-id={id}
187-
>
188-
<div style={innerStyle} onClick={onOpenPopover} className={classes.header} data-h-align={column.hAlign}>
189-
<Text
190-
tooltip={typeof children === 'string' ? children : null}
191-
wrapping={false}
192-
style={textStyle}
193-
className={classes.text}
194-
>
195-
{children}
196-
</Text>
197-
<div className={classes.iconContainer}>
198-
{filterIcon}
199-
{sortingIcon}
200-
{groupingIcon}
165+
<>
166+
<div
167+
id={id}
168+
className={className}
169+
style={{
170+
...style,
171+
cursor: hasPopover ? 'pointer' : 'auto',
172+
borderLeft: dragOver ? `3px solid ${ThemingParameters.sapSelectedColor}` : undefined
173+
}}
174+
role={role}
175+
draggable={isDraggable}
176+
onDragEnter={onDragEnter}
177+
onDragOver={onDragOver}
178+
onDragStart={onDragStart}
179+
onDrop={onDrop}
180+
onDragEnd={onDragEnd}
181+
data-column-id={id}
182+
onClick={onOpenPopover}
183+
>
184+
<div className={classes.header} data-h-align={column.hAlign}>
185+
<Text
186+
tooltip={typeof children === 'string' ? children : null}
187+
wrapping={false}
188+
style={textStyle}
189+
className={classes.text}
190+
>
191+
{children}
192+
</Text>
193+
<div className={classes.iconContainer}>
194+
{isFiltered && <Icon name="filter" />}
195+
{column.isSorted && <Icon name={column.isSortedDesc ? 'sort-descending' : 'sort-ascending'} />}
196+
{column.isGrouped && <Icon name="group-2" />}
197+
</div>
201198
</div>
199+
{hasPopover && <ColumnHeaderModal column={column} onSort={onSort} onGroupBy={onGroupBy} ref={popoverRef} />}
202200
</div>
203-
{hasPopover && <ColumnHeaderModal column={column} onSort={onSort} onGroupBy={onGroupBy} ref={popoverRef} />}
204201
{column.canResize && column.getResizerProps && (
205-
<div {...column.getResizerProps()} data-resizer className={`${classes.resizer}`} />
202+
<div
203+
{...column.getResizerProps()}
204+
data-resizer
205+
className={classes.resizer}
206+
style={{ left: `${column.totalLeft + column.totalFlexWidth}px` }}
207+
/>
206208
)}
207-
</div>
209+
</>
208210
);
209211
};

0 commit comments

Comments
 (0)