[Lens] Avoid suggestion rendering and evaluation on fullscreen mode (#102757)

This commit is contained in:
Marco Liberati 2021-06-23 10:27:27 +02:00 committed by GitHub
parent 1315521760
commit 7733950bde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 4 deletions

View file

@ -1370,6 +1370,57 @@ describe('editor_frame', () => {
})
);
});
it('should avoid completely to compute suggestion when in fullscreen mode', async () => {
const props = {
...getDefaultProps(),
initialContext: {
indexPatternId: '1',
fieldName: 'test',
},
visualizationMap: {
testVis: mockVisualization,
},
datasourceMap: {
testDatasource: mockDatasource,
testDatasource2: mockDatasource2,
},
ExpressionRenderer: expressionRendererMock,
};
const { instance: el } = await mountWithProvider(
<EditorFrame {...props} />,
props.plugins.data
);
instance = el;
expect(
instance.find(FrameLayout).prop('suggestionsPanel') as ReactElement
).not.toBeUndefined();
await act(async () => {
(instance.find(FrameLayout).prop('dataPanel') as ReactElement)!.props.dispatch({
type: 'TOGGLE_FULLSCREEN',
});
});
instance.update();
expect(instance.find(FrameLayout).prop('suggestionsPanel') as ReactElement).toBe(false);
await act(async () => {
(instance.find(FrameLayout).prop('dataPanel') as ReactElement)!.props.dispatch({
type: 'TOGGLE_FULLSCREEN',
});
});
instance.update();
expect(
instance.find(FrameLayout).prop('suggestionsPanel') as ReactElement
).not.toBeUndefined();
});
});
describe('passing state back to the caller', () => {

View file

@ -452,7 +452,8 @@ export function EditorFrame(props: EditorFrameProps) {
)
}
suggestionsPanel={
allLoaded && (
allLoaded &&
!state.isFullscreenDatasource && (
<SuggestionPanel
frame={framePublicAPI}
activeDatasourceId={state.activeDatasourceId}

View file

@ -88,9 +88,8 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */
position: relative;
}
.lnsFrameLayout-isFullscreen .lnsFrameLayout__sidebar--left,
.lnsFrameLayout-isFullscreen .lnsFrameLayout__suggestionPanel {
// Hide the datapanel and suggestions in fullscreen mode. Using display: none does trigger
.lnsFrameLayout-isFullscreen .lnsFrameLayout__sidebar--left {
// Hide the datapanel in fullscreen mode. Using display: none does trigger
// a rerender when the container becomes visible again, maybe pushing offscreen is better
display: none;
}