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: the grid body is hidden after resizing the grid #1475

Merged
merged 1 commit into from
Oct 6, 2021
Merged
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
24 changes: 22 additions & 2 deletions packages/toast-ui.grid/src/view/bodyArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface StoreProps {
cellBorderWidth: number;
eventBus: EventBus;
hasTreeColumn: boolean;
visibleTotalWidth: number;
}

type Props = OwnProps & StoreProps & DispatchProps;
Expand Down Expand Up @@ -79,6 +80,7 @@ const PROPS_FOR_UPDATE: (keyof StoreProps)[] = [
'offsetLeft',
'offsetTop',
'totalColumnWidth',
'visibleTotalWidth',
];
// Minimum distance (pixel) to detect if user wants to drag when moving mouse with button pressed.
const MIN_DISTANCE_FOR_DRAG = 10;
Expand Down Expand Up @@ -422,6 +424,7 @@ class BodyAreaComp extends Component<Props> {
scrollX,
scrollY,
cellBorderWidth,
visibleTotalWidth,
}: Props) {
const areaStyle: AreaStyle = { height: bodyHeight };
if (!scrollX) {
Expand All @@ -431,6 +434,7 @@ class BodyAreaComp extends Component<Props> {
areaStyle.overflowY = 'hidden';
}
const tableContainerStyle = {
width: visibleTotalWidth,
top: offsetTop,
left: offsetLeft,
height: dummyRowCount ? bodyHeight - scrollXHeight : '',
Expand Down Expand Up @@ -470,9 +474,24 @@ class BodyAreaComp extends Component<Props> {
export const BodyArea = connect<StoreProps, OwnProps>((store, { side }) => {
const { columnCoords, rowCoords, dimension, viewport, id, column } = store;
const { totalRowHeight } = rowCoords;
const { totalColumnWidth } = columnCoords;
const { totalColumnWidth, widths } = columnCoords;
const { bodyHeight, scrollXHeight, scrollX, scrollY, cellBorderWidth } = dimension;
const { offsetLeft, offsetTop, scrollTop, scrollLeft, dummyRowCount } = viewport;
const {
offsetLeft,
offsetTop,
scrollTop,
scrollLeft,
dummyRowCount,
colRange,
columns,
} = viewport;

const visibleWidths = side === 'R' ? widths[side].slice(...colRange) : widths[side];
const visibleColumns = side === 'R' ? columns : column.visibleColumnsBySideWithRowHeader[side];
const visibleTotalWidth = visibleColumns.reduce(
(acc, _, idx) => acc + visibleWidths[idx] + cellBorderWidth,
0
);

return {
bodyHeight,
Expand All @@ -489,5 +508,6 @@ export const BodyArea = connect<StoreProps, OwnProps>((store, { side }) => {
cellBorderWidth,
eventBus: getEventBus(id),
hasTreeColumn: !!column.treeColumnName,
visibleTotalWidth,
};
})(BodyAreaComp);