@@ -14,15 +14,10 @@ import TableChildrenRenderer, {getElementChildren} from './TableChildrenRenderer
1414import TableColumnAlignmentContext from './TableColumnAlignmentContext' ;
1515import TableContentWidthContext from './TableContentWidthContext' ;
1616
17- /** Whether `node` has a descendant with the given tag name. */
18- function hasDescendantTag ( node : TNode , tagName : string ) : boolean {
19- return node . children ?. some ( ( child ) => child . tagName === tagName || hasDescendantTag ( child , tagName ) ) ?? false ;
20- }
21-
2217/**
23- * Derives the horizontal alignment for each column from the table body. The Concierge HTML wraps amount values in
24- * `<strong>` and carries no alignment attributes, so a column whose body cells are all amounts is right-aligned to
25- * match how amounts are shown elsewhere in the app; every other column stays left-aligned.
18+ * Derives the horizontal alignment for each column from the table body. Concierge expense tables put the amount in
19+ * the last column and carry no alignment attributes, so the last column is right-aligned to match how amounts are
20+ * shown elsewhere in the app; every other column stays left-aligned.
2621 */
2722function getColumnAlignments ( tableNode : TNode ) : CellHorizontalAlignment [ ] {
2823 const bodyRows = getElementChildren ( tableNode )
@@ -33,11 +28,7 @@ function getColumnAlignments(tableNode: TNode): CellHorizontalAlignment[] {
3328 }
3429
3530 const columnCount = bodyRows . reduce ( ( max , row ) => Math . max ( max , getElementChildren ( row ) . length ) , 0 ) ;
36- return Array . from ( { length : columnCount } , ( _ , columnIndex ) => {
37- const columnCells = bodyRows . map ( ( row ) => getElementChildren ( row ) . at ( columnIndex ) ) . filter ( ( cell ) : cell is TNode => ! ! cell ) ;
38- const isAmountColumn = columnCells . length > 0 && columnCells . every ( ( cell ) => hasDescendantTag ( cell , 'strong' ) ) ;
39- return isAmountColumn ? 'right' : 'left' ;
40- } ) ;
31+ return Array . from ( { length : columnCount } , ( _ , columnIndex ) => ( columnIndex === columnCount - 1 ? 'right' : 'left' ) ) ;
4132}
4233
4334function TableRenderer ( { tnode} : CustomRendererProps < TBlock > ) {
0 commit comments