From d05047c0702a148fca8b0996962cde6ed07b55f2 Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Wed, 15 May 2024 09:46:15 +0200 Subject: [PATCH 1/4] [Discover] Fix JSON view height in DocViewer --- .../public/components/doc_viewer_source/source.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx index 26ac6cb01b71e..a3f0bd1e93783 100644 --- a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx @@ -36,7 +36,7 @@ interface SourceViewerProps { // inline limitation was necessary to enable virtualized scrolling, which improves performance export const MAX_LINES_CLASSIC_TABLE = 500; // Displayed margin of the code editor to the window bottom when rendered in the document explorer flyout -export const MARGIN_BOTTOM = 25; +export const MARGIN_BOTTOM = 80; // Minimum height for the source content to guarantee minimum space when the flyout is scrollable. export const MIN_HEIGHT = 400; @@ -54,7 +54,7 @@ export const DocViewerSource = ({ const [jsonValue, setJsonValue] = useState(''); const { uiSettings } = getUnifiedDocViewerServices(); const useNewFieldsApi = !uiSettings.get(SEARCH_FIELDS_FROM_SOURCE); - const useDocExplorer = isLegacyTableEnabled({ + const useDocExplorer = !isLegacyTableEnabled({ uiSettings, isTextBasedQueryMode: Array.isArray(textBasedHits), }); From 423aaa319ee86ef31d024340bf9c206452037786 Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Wed, 15 May 2024 09:46:55 +0200 Subject: [PATCH 2/4] [Discover] Add a comment --- .../public/components/doc_viewer_source/source.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx index a3f0bd1e93783..740afc99a9c62 100644 --- a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx @@ -36,7 +36,7 @@ interface SourceViewerProps { // inline limitation was necessary to enable virtualized scrolling, which improves performance export const MAX_LINES_CLASSIC_TABLE = 500; // Displayed margin of the code editor to the window bottom when rendered in the document explorer flyout -export const MARGIN_BOTTOM = 80; +export const MARGIN_BOTTOM = 80; // DocViewer flyout has a footer // Minimum height for the source content to guarantee minimum space when the flyout is scrollable. export const MIN_HEIGHT = 400; From f33005d24a1c76b00f51a0ee0cb2b1ca500265a3 Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Wed, 15 May 2024 11:06:43 +0200 Subject: [PATCH 3/4] [Discover] Revert padding change --- .../public/components/doc_viewer_source/source.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx index 740afc99a9c62..13f2ee065f504 100644 --- a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx @@ -36,7 +36,7 @@ interface SourceViewerProps { // inline limitation was necessary to enable virtualized scrolling, which improves performance export const MAX_LINES_CLASSIC_TABLE = 500; // Displayed margin of the code editor to the window bottom when rendered in the document explorer flyout -export const MARGIN_BOTTOM = 80; // DocViewer flyout has a footer +export const MARGIN_BOTTOM = 25; // Minimum height for the source content to guarantee minimum space when the flyout is scrollable. export const MIN_HEIGHT = 400; From 6e3873b49086913e2ef231ec277f2c137f8e130d Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Wed, 15 May 2024 11:09:46 +0200 Subject: [PATCH 4/4] [Discover] Update tests --- .../public/components/doc_viewer_source/get_height.test.tsx | 3 ++- .../public/components/doc_viewer_source/source.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.test.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.test.tsx index 6c6ae2852e053..e28df4d89d5bc 100644 --- a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.test.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.test.tsx @@ -8,6 +8,7 @@ import { monaco } from '@kbn/monaco'; import { getHeight } from './get_height'; +import { MARGIN_BOTTOM } from './source'; describe('getHeight', () => { Object.defineProperty(window, 'innerHeight', { writable: true, configurable: true, value: 500 }); @@ -32,7 +33,7 @@ describe('getHeight', () => { const monacoMock = getMonacoMock(500, 0); const height = getHeight(monacoMock, true); - expect(height).toBe(475); + expect(height).toBe(500 - MARGIN_BOTTOM); }); test('when using document explorer, returning the available height in the flyout has a minimun guarenteed height', () => { diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx index 13f2ee065f504..740afc99a9c62 100644 --- a/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx @@ -36,7 +36,7 @@ interface SourceViewerProps { // inline limitation was necessary to enable virtualized scrolling, which improves performance export const MAX_LINES_CLASSIC_TABLE = 500; // Displayed margin of the code editor to the window bottom when rendered in the document explorer flyout -export const MARGIN_BOTTOM = 25; +export const MARGIN_BOTTOM = 80; // DocViewer flyout has a footer // Minimum height for the source content to guarantee minimum space when the flyout is scrollable. export const MIN_HEIGHT = 400;