Skip to content

Commit

Permalink
[BUG] Fix Discover table panel size auto adjust in Dashboard
Browse files Browse the repository at this point in the history
* Add React.memo on parent comp
* Restore embeddable panel style

Issue Resolve
opensearch-project#5415

Signed-off-by: ananzh <ananzh@amazon.com>
  • Loading branch information
ananzh committed Nov 8, 2023
1 parent 1de8be6 commit 9a4ddc3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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))
- [BUG] Fix Discover table panel size auto adjust in Dashboard ([#5441](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5441))

### 🚞 Infrastructure

Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data_explorer/public/components/app_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ export const AppContainer = ({ view, params }: { view?: View; params: AppMountPa

const { Canvas, Panel, Context } = view;

const MemorizedCanvas = React.memo(Canvas);
const MemorizedPanel = React.memo(Panel);

// Render the application DOM.
return (
<EuiPage className="deLayout" paddingSize="none">
{/* TODO: improve fallback state */}
<Suspense fallback={<div>Loading...</div>}>
<Context {...params}>
<Sidebar>
<Panel {...params} />
<MemorizedPanel {...params} />
</Sidebar>
<EuiPageBody className="deLayout__canvas">
<Canvas {...params} />
<MemorizedCanvas {...params} />
</EuiPageBody>
</Context>
</Suspense>
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
20 changes: 20 additions & 0 deletions src/plugins/discover/public/embeddable/search_embeddable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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 */

.dscDiscoverGrid {
flex-direction: column;
flex: 1 1 0;
overflow: auto;

@include euiScrollBar;
}
}
}
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,8 +52,10 @@ export function SearchEmbeddableComponent({ searchProps }: SearchEmbeddableProps
data-test-subj="embeddedSavedSearchDocTable"
>
{discoverEmbeddableProps.totalHitCount !== 0 ? (
<EuiFlexItem>
<DataGridTableMemoized {...discoverEmbeddableProps} />
<EuiFlexItem style={{ minHeight: 0 }}>
<div className="osdDocTable__container">
<DataGridTableMemoized {...discoverEmbeddableProps} />
</div>
</EuiFlexItem>
) : (
<EuiFlexItem>
Expand Down

0 comments on commit 9a4ddc3

Please sign in to comment.