mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Security Solution][Expandable flyout] add ability for user to resize the flyout and the left/right section even if preview is rendered (#211938)
## Summary This PR makes a couple of small changes to the expandable flyout package: - get rid of an unwanted white space when preview are shown - allow the user to resize the flyout and the internal left/right sections when a preview is rendered #### White space removal | Before | After | | ------------- | ------------- | |  |  | #### Allow resize even when previews are shown https://github.com/user-attachments/assets/034f59c2-6c4a-4efa-a817-8c23dbc11b60 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
89e2cc54f9
commit
a4c7c8b28e
4 changed files with 5 additions and 42 deletions
|
@ -218,7 +218,6 @@ export const Container: React.FC<ContainerProps> = memo(
|
|||
leftComponent={leftComponent as React.ReactElement}
|
||||
rightComponent={rightComponent as React.ReactElement}
|
||||
showLeft={showExpanded}
|
||||
showPreview={showPreview}
|
||||
/>
|
||||
|
||||
{showPreview && (
|
||||
|
|
|
@ -12,8 +12,8 @@ import {
|
|||
EuiFlexItem,
|
||||
EuiSplitPanel,
|
||||
EuiText,
|
||||
useEuiTheme,
|
||||
transparentize,
|
||||
useEuiTheme,
|
||||
} from '@elastic/eui';
|
||||
import React, { memo, useMemo } from 'react';
|
||||
import { css } from '@emotion/react';
|
||||
|
@ -100,7 +100,8 @@ export const PreviewSection: React.FC<PreviewSectionProps> = memo(
|
|||
const percentage = rightPercentage
|
||||
? rightPercentage
|
||||
: defaultPercentages[type].rightPercentage;
|
||||
return showExpanded ? `calc(${percentage}% - 8px)` : `calc(100% - 8px)`;
|
||||
// we need to keep 1px here to make sure users can click on the EuiResizableButton and resize the flyout with preview opened
|
||||
return showExpanded ? `calc(${percentage}% - 1px)` : `calc(100% - 1px)`;
|
||||
}, [defaultPercentages, rightPercentage, showExpanded, type]);
|
||||
|
||||
const closeButton = (
|
||||
|
|
|
@ -38,7 +38,6 @@ describe('ResizableContainer', () => {
|
|||
leftComponent={leftComponent}
|
||||
rightComponent={rightComponent}
|
||||
showLeft={false}
|
||||
showPreview={false}
|
||||
/>
|
||||
</TestProvider>
|
||||
);
|
||||
|
@ -74,7 +73,6 @@ describe('ResizableContainer', () => {
|
|||
leftComponent={leftComponent}
|
||||
rightComponent={rightComponent}
|
||||
showLeft={true}
|
||||
showPreview={false}
|
||||
/>
|
||||
</TestProvider>
|
||||
);
|
||||
|
@ -91,32 +89,4 @@ describe('ResizableContainer', () => {
|
|||
expect(leftSection).toBeInTheDocument();
|
||||
expect(leftSection.parentElement).toHaveStyle('inline-size: 50%; block-size: auto;');
|
||||
});
|
||||
|
||||
it('should disable the resize button if preview is rendered', () => {
|
||||
const state = {
|
||||
...initialState,
|
||||
ui: {
|
||||
...initialState.ui,
|
||||
userSectionWidths: {
|
||||
leftPercentage: 50,
|
||||
rightPercentage: 50,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProvider state={state}>
|
||||
<ResizableContainer
|
||||
leftComponent={leftComponent}
|
||||
rightComponent={rightComponent}
|
||||
showLeft={true}
|
||||
showPreview={true}
|
||||
/>
|
||||
</TestProvider>
|
||||
);
|
||||
|
||||
const resizeButton = getByTestId(RESIZABLE_BUTTON_TEST_ID);
|
||||
expect(resizeButton).toBeInTheDocument();
|
||||
expect(resizeButton).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,10 +41,6 @@ interface ResizableContainerProps {
|
|||
* If the left section is not shown we disable the resize button and hide the left size of the resizable panel
|
||||
*/
|
||||
showLeft: boolean;
|
||||
/**
|
||||
* If the preview section is shown we disable the resize button
|
||||
*/
|
||||
showPreview: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +48,7 @@ interface ResizableContainerProps {
|
|||
* It allows the resizing of the sections, saving the percentages in local storage.
|
||||
*/
|
||||
export const ResizableContainer: React.FC<ResizableContainerProps> = memo(
|
||||
({ leftComponent, rightComponent, showLeft, showPreview }: ResizableContainerProps) => {
|
||||
({ leftComponent, rightComponent, showLeft }: ResizableContainerProps) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const { leftPercentage, rightPercentage } = useSelector(selectUserSectionWidths);
|
||||
|
@ -97,10 +93,7 @@ export const ResizableContainer: React.FC<ResizableContainerProps> = memo(
|
|||
>
|
||||
<LeftSection component={leftComponent} />
|
||||
</EuiResizablePanel>
|
||||
<EuiResizableButton
|
||||
disabled={showPreview || !showLeft}
|
||||
data-test-subj={RESIZABLE_BUTTON_TEST_ID}
|
||||
/>
|
||||
<EuiResizableButton disabled={!showLeft} data-test-subj={RESIZABLE_BUTTON_TEST_ID} />
|
||||
<EuiResizablePanel
|
||||
id={RIGHT_PANEL_ID}
|
||||
initialSize={initialRightPercentage}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue