Skip to content

Commit

Permalink
[BUG] Fix Discover table panel size auto adjust in Dashboard (#5441)
Browse files Browse the repository at this point in the history
* [BUG] Fix Discover table panel size auto adjust in Dashboard

* Add React.memo on parent comp
* Restore embeddable panel style

Issue Resolve
#5415

Co-authored-by: Miki <amoo_miki@yahoo.com>
Signed-off-by: Anan Zhuang <ananzh@amazon.com>

---------

Signed-off-by: ananzh <ananzh@amazon.com>
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
Co-authored-by: Miki <amoo_miki@yahoo.com>
  • Loading branch information
ananzh and AMoo-Miki authored Nov 9, 2023
1 parent 088fc66 commit e0b6006
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [BUG] Add platform "darwin-arm64" to unit test ([#5290](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5290))
- [BUG][Dev Tool] Add dev tool documentation link to dev tool's help menu [#5166](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5166)
- Fix navigation issue across dashboards ([#5435](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5435))
- [Discover] Fix table panel auto-sizing ([#5441](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5441))

### 🚞 Infrastructure

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { DataGridFlyout } from './data_grid_table_flyout';
import { DiscoverGridContextProvider } from './data_grid_table_context';
import { toolbarVisibility } from './constants';
import { DocViewFilterFn, OpenSearchSearchHit } from '../../doc_views/doc_views_types';
import { DiscoverServices } from '../../../build_services';
import { usePagination } from '../utils/use_pagination';
import { SortOrder } from '../../../saved_searches/types';
import { buildColumns } from '../../utils/columns';
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/discover/public/embeddable/search_embeddable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* 1. We want the osdDocTable__container to scroll only when embedded in an embeddable panel
* 2. Force a better looking scrollbar
*/
.embPanel {
.osdDocTable__container {
@include euiScrollBar; /* 2 */

flex: 1 1 0; /* 1 */
overflow: auto; /* 1 */
}
}
4 changes: 3 additions & 1 deletion src/plugins/discover/public/embeddable/search_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ export class SearchEmbeddable
const props = {
searchProps,
};
ReactDOM.render(<SearchEmbeddableComponent {...props} />, node);

const MemorizedSearchEmbeddableComponent = React.memo(SearchEmbeddableComponent);
ReactDOM.render(<MemorizedSearchEmbeddableComponent {...props} />, node);
}

private async pushContainerStateParamsToProps(searchProps: SearchProps, force: boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
DataGridTableProps,
} from '../application/components/data_grid/data_grid_table';
import { VisualizationNoResults } from '../../../visualizations/public';
import './search_embeddable.scss';

interface SearchEmbeddableProps {
searchProps: SearchProps;
Expand Down Expand Up @@ -51,7 +52,7 @@ export function SearchEmbeddableComponent({ searchProps }: SearchEmbeddableProps
data-test-subj="embeddedSavedSearchDocTable"
>
{discoverEmbeddableProps.totalHitCount !== 0 ? (
<EuiFlexItem>
<EuiFlexItem style={{ minHeight: 0 }} className="osdDocTable__container">
<DataGridTableMemoized {...discoverEmbeddableProps} />
</EuiFlexItem>
) : (
Expand Down

0 comments on commit e0b6006

Please sign in to comment.