All files / src/features/Settings/Team/helpers pahSectionLayout.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 3811x 11x 11x                             11x     132x                 11x       94x        
const ONE_ROW_HEIGHT_PX = 212;
const ONE_ROW_HEIGHT_COMPACT_PX = 160;
const ROW_HEIGHT_PX = 72;
 
/**
 * Definite pixel height for a wrapper around a nested V2 table.
 *
 * A nested table renders with `height: 100%` / `minHeight:
 * -webkit-fill-available`, which only resolve against a definite-height
 * ancestor. If the wrapper uses a non-definite height (minHeight/auto) the
 * table's scroll body collapses and the rows disappear entirely. So this MUST
 * return a concrete px value; it grows by one 72px row per extra row.
 *
 * `oneRowHeightPx` is the section's own single-row height — its heading
 * paddings and whether it draws a column-header strip differ per section, so
 * each caller owns that number and only the arithmetic is shared.
 */
export const getNestedTableSectionHeight = (
  rowCount: number,
  oneRowHeightPx: number,
): string => `${oneRowHeightPx + Math.max(0, rowCount - 1) * ROW_HEIGHT_PX}px`;
 
/**
 * Definite pixel height for the "Primary Account Holder" section wrapper.
 *
 * See `getNestedTableSectionHeight` for why this must be a px value (a
 * regression fixed here). It grows by one row height per extra row so a pending
 * reassignment's second PAH row fits.
 */
export const getPahSectionHeight = (
  rowCount: number,
  isCompact: boolean,
): string =>
  getNestedTableSectionHeight(
    rowCount,
    isCompact ? ONE_ROW_HEIGHT_COMPACT_PX : ONE_ROW_HEIGHT_PX,
  );