Skip to content
Open
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
20 changes: 11 additions & 9 deletions packages/main/src/components/AnalyticalTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ import type {
AnalyticalTableState,
DivWithCustomScrollProp
} from './types/index.js';
import { getRowHeight, getSubRowsByString, tagNamesWhichShouldNotSelectARow } from './util/index.js';
import {
getCombinedElementsHeight,
getRowHeight,
getSubRowsByString,
tagNamesWhichShouldNotSelectARow
} from './util/index.js';
import { VerticalResizer } from './VerticalResizer.js';

// When a sorted column is removed from the visible columns array (e.g. when "popped-in"), it doesn't clean up the sorted columns leading to an undefined `sortType`.
Expand Down Expand Up @@ -351,14 +356,11 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
tableInstance(tableInstanceRef.current);
}

const titleBarRef = useRef(null);
const extensionRef = useRef(null);
const headerRef = useRef(null);

const extensionsHeight =
(titleBarRef.current?.offsetHeight ?? 0) +
(extensionRef.current?.offsetHeight ?? 0) +
(headerRef.current?.offsetHeight ?? 0);
const prevExtensionsHeight = useRef<number>(0);
const titleBarRef = useRef<HTMLDivElement>(null);
const extensionRef = useRef<HTMLDivElement>(null);
const headerRef = useRef<HTMLDivElement>(null);
const extensionsHeight = getCombinedElementsHeight(prevExtensionsHeight, titleBarRef, extensionRef, headerRef);

const internalRowHeight = getRowHeight(rowHeight, tableRef);
const internalHeaderRowHeight = headerRowHeight ?? internalRowHeight;
Expand Down
22 changes: 22 additions & 0 deletions packages/main/src/components/AnalyticalTable/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,25 @@ export function getLeafHeaders(header) {
recurseHeader(header);
return leafHeaders;
}

export const getCombinedElementsHeight = (
prevHeightRef: RefObject<number>,
...refs: RefObject<HTMLElement>[]
): number => {
const prevHeight = prevHeightRef.current;
let height = 0;

for (const ref of refs) {
const el = ref.current;
if (!el) {
continue;
}
height += el.offsetHeight;
}
// Math.abs is required, because of subpixel rounding errors
const updatedHeight = Math.abs(prevHeight - height) > 1 ? height : prevHeight;
//@ts-expect-error: downport from v2
prevHeightRef.current = updatedHeight;

return updatedHeight;
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useRef } from 'react';
import { ValueState } from '../../enums/index.js';
import { Link } from '../../webComponents/Link/index.js';
import { MessageItem } from './MessageItem';
import { MessageView } from './index.js';
import { Link } from '../../webComponents/Link/index.js';

describe('MessageView', () => {
it('default & grouped', () => {
Expand Down
Loading