[Security Solution] Enable repositionOnScroll for overflow popovers (#110584)

* enable repositionOnScroll

* unit test

* update test case

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Angela Chuang 2021-09-01 19:50:33 +01:00 committed by GitHub
parent 508d045f90
commit 9dec97b5f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import { shallow } from 'enzyme';
import OverflowButton from './overflow';
describe('OverflowButton', () => {
const props = {
field: 'host.name',
ownFocus: false,
showTooltip: true,
value: 'mac',
closePopOver: jest.fn(),
items: [<div />],
isOverflowPopoverOpen: false,
};
test('should render a popover', () => {
const wrapper = shallow(<OverflowButton {...props} />);
expect(wrapper.find('EuiPopover').exists()).toBeTruthy();
});
test('the popover always contains a class that hides it when an overlay (e.g. the inspect modal) is displayed', () => {
const wrapper = shallow(<OverflowButton {...props} />);
expect(wrapper.find('EuiPopover').prop('panelClassName')).toEqual('withHoverActions__popover');
});
test('should enable repositionOnScroll', () => {
const wrapper = shallow(<OverflowButton {...props} />);
expect(wrapper.find('EuiPopover').prop('repositionOnScroll')).toEqual(true);
});
test('should render a tooltip if showTooltip is true', () => {
const testProps = {
...props,
showTooltip: true,
};
const wrapper = shallow(<OverflowButton {...testProps} />);
expect(wrapper.find('EuiToolTip').exists()).toBeTruthy();
});
});

View file

@ -97,6 +97,7 @@ const OverflowButton: React.FC<OverflowButtonProps> = React.memo(
closePopover={closePopOver}
panelPaddingSize="none"
panelClassName="withHoverActions__popover"
repositionOnScroll={true}
anchorPosition="downLeft"
>
<StyledEuiContextMenuPanel items={items} />