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
…5452)

* [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 <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>

---------

Signed-off-by: ananzh <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit e0b6006)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
opensearch-trigger-bot[bot] and AMoo-Miki authored Nov 9, 2023
1 parent ce72604 commit 361df77
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
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 361df77

Please sign in to comment.