Skip to content

Commit

Permalink
fix(legacy-table): container height on tall headers (apache#398)
Browse files Browse the repository at this point in the history
* fix(legacy-table): container height on tall headers

* fix(legacy-table): possible undefined lint error
  • Loading branch information
ktmud authored and zhaoyongjie committed Nov 25, 2021
1 parent ac32188 commit 9048425
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,13 @@ export default function ReactDataTable(props: DataTableProps) {
const dataTable = $root.find('table').DataTable(options);

// adjust table height
const scrollHeadHeight = 34;
const paginationHeight = hasPagination ? 35 : 0;
const searchBarHeight = hasPagination || includeSearch ? 35 : 0;
const scrollHeadHeight = $root.find('.dataTables_scrollHead').height() || 0;
const paginationHeight = $root.find('.dataTables_paginate').height() || 0;
const searchBarHeight =
$root
.find('.dataTables_length,.dataTables_filter')
.closest('.row')
.height() || 0;
const scrollBodyHeight = viewportHeight - scrollHeadHeight - paginationHeight - searchBarHeight;
$root.find('.dataTables_scrollBody').css('max-height', scrollBodyHeight);

Expand Down Expand Up @@ -238,7 +242,7 @@ export default function ReactDataTable(props: DataTableProps) {
style={{
backgroundImage: keyIsMetric ? cellBar(key, val as number) : undefined,
}}
title={keyIsMetric || percentMetricsSet.has(key) ? (val as string) : ''}
title={keyIsMetric || percentMetricsSet.has(key) ? String(val) : ''}
>
{isHtml ? null : text}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"gender": "gender",
"name": "name",
"num": "num",
"state": "state",
"state": "state (this is a very very very long column)",
"sum_boys": "sum_boys",
"sum_girls": "sum_girls"
},
Expand Down

0 comments on commit 9048425

Please sign in to comment.