Skip to content

Commit f36b855

Browse files
authored
Merge branch 'main' into feat/ui5wc-2.14.0
2 parents fd282a2 + 703dfec commit f36b855

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ import type {
8989
TableInstance,
9090
CellInstance,
9191
} from './types/index.js';
92-
import { getRowHeight, getSubRowsByString, tagNamesWhichShouldNotSelectARow } from './util/index.js';
92+
import {
93+
getCombinedElementsHeight,
94+
getRowHeight,
95+
getSubRowsByString,
96+
tagNamesWhichShouldNotSelectARow,
97+
} from './util/index.js';
9398
import { VerticalResizer } from './VerticalResizer.js';
9499

95100
// 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`.
@@ -387,14 +392,11 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
387392
tableInstance(tableInstanceRef.current);
388393
}
389394

390-
const titleBarRef = useRef(null);
391-
const extensionRef = useRef(null);
392-
const headerRef = useRef(null);
393-
394-
const extensionsHeight =
395-
(titleBarRef.current?.offsetHeight ?? 0) +
396-
(extensionRef.current?.offsetHeight ?? 0) +
397-
(headerRef.current?.offsetHeight ?? 0);
395+
const prevExtensionsHeight = useRef<number>(0);
396+
const titleBarRef = useRef<HTMLDivElement>(null);
397+
const extensionRef = useRef<HTMLDivElement>(null);
398+
const headerRef = useRef<HTMLDivElement>(null);
399+
const extensionsHeight = getCombinedElementsHeight(prevExtensionsHeight, titleBarRef, extensionRef, headerRef);
398400

399401
const internalRowHeight = getRowHeight(rowHeight, tableRef);
400402
const internalHeaderRowHeight = headerRowHeight ?? internalRowHeight;

packages/main/src/components/AnalyticalTable/util/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,24 @@ export function getLeafHeaders(header) {
189189
recurseHeader(header);
190190
return leafHeaders;
191191
}
192+
193+
export const getCombinedElementsHeight = (
194+
prevHeightRef: RefObject<number>,
195+
...refs: RefObject<HTMLElement>[]
196+
): number => {
197+
const prevHeight = prevHeightRef.current;
198+
let height = 0;
199+
200+
for (const ref of refs) {
201+
const el = ref.current;
202+
if (!el) {
203+
continue;
204+
}
205+
height += el.offsetHeight;
206+
}
207+
// Math.abs is required, because of subpixel rounding errors
208+
const updatedHeight = Math.abs(prevHeight - height) > 1 ? height : prevHeight;
209+
prevHeightRef.current = updatedHeight;
210+
211+
return updatedHeight;
212+
};

0 commit comments

Comments
 (0)