Skip to content

Commit

Permalink
Make table size adjustable according to table rows and columns
Browse files Browse the repository at this point in the history
* Provide a unique key prop to the table component to force it to fully
re-render when the key changes, which will force table to adjust its size.

Issue Resolved
opensearch-project#5440

Signed-off-by: Anan Z <[email protected]>
  • Loading branch information
ananzh committed Feb 5, 2024
1 parent 7c0bd9f commit d2424ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [BUG][Discover] Fix advanced setting `discover:modifyColumnsOnSwitch` ([#5508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5508))
- [BUG][Discover] Show 0 filters when there are no active filters ([#5508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5508))
- [Discover] Fix missing index pattern field from breaking Discover [#5626](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5626)
<<<<<<< HEAD
- [BUG] Remove duplicate sample data as id 90943e30-9a47-11e8-b64d-95841ca0b247 ([5668](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5668))
- [BUG][Multiple Datasource] Fix datasource testing connection unexpectedly passed with wrong endpoint [#5663](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5663)
=======
- [BUG][Discover] Make table size adjustable according to table rows and columns ([#5514](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5514))
>>>>>>> c5f5c61f730... Make table size adjustable according to table rows and columns
### 🚞 Infrastructure

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history }: ViewPro
}, [dispatch, filteredColumns, indexPattern]);

const timeField = indexPattern?.timeFieldName ? indexPattern.timeFieldName : undefined;
const lastColumn = columns ? columns[columns.length - 1] : '';

if (!rows || rows.length === 0) {
// TODO: handle better
return <div>{'loading...'}</div>;
}

return (
<EuiPanel
Expand Down Expand Up @@ -118,7 +124,7 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history }: ViewPro
<MemoizedDiscoverChartContainer {...fetchState} />
</EuiPanel>
</EuiPanel>
<MemoizedDiscoverTable rows={rows} />
<MemoizedDiscoverTable key={`table-${rows?.length}-${lastColumn}`} rows={rows} />
</>
)}
</EuiPanel>
Expand Down

0 comments on commit d2424ef

Please sign in to comment.