Skip to content

Commit

Permalink
[SECURITY] Bug truncation on timeline (#72221) (#72268)
Browse files Browse the repository at this point in the history
* bring back truncated ceil + only show menu context hover text

* update unit test
  • Loading branch information
XavierM authored Jul 17, 2020
1 parent 9881383 commit f1ab2c6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ describe('AddFilterToGlobalSearchBar Component', () => {
</TestProviders>
);

wrapper.find('[data-test-subj="withHoverActionsButton"]').simulate('mouseenter');
wrapper.update();

wrapper
.simulate('mouseenter')
.find('[data-test-subj="hover-actions-container"] [data-euiicon-type]')
.first()
.simulate('click');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('DraggableWrapper', () => {
expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(false);
});

test('it renders hover actions when the mouse is over the draggable wrapper', () => {
test('it renders hover actions when the mouse is over the text of draggable wrapper', () => {
const wrapper = mount(
<TestProviders>
<MockedProvider mocks={mocksSource} addTypename={false}>
Expand All @@ -76,7 +76,7 @@ describe('DraggableWrapper', () => {
</TestProviders>
);

wrapper.simulate('mouseenter');
wrapper.find('[data-test-subj="withHoverActionsButton"]').simulate('mouseenter');
wrapper.update();
expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const WithHoverActionsPopover = (styled(EuiPopover as any)`
}
` as unknown) as typeof EuiPopover;

const Container = styled.div`
width: fit-content;
`;

interface Props {
/**
* Always show the hover menu contents (default: false)
Expand Down Expand Up @@ -68,7 +64,14 @@ export const WithHoverActions = React.memo<Props>(
setShowHoverContent(false);
}, []);

const content = useMemo(() => <>{render(showHoverContent)}</>, [render, showHoverContent]);
const content = useMemo(
() => (
<div data-test-subj="withHoverActionsButton" onMouseEnter={onMouseEnter}>
{render(showHoverContent)}
</div>
),
[onMouseEnter, render, showHoverContent]
);

useEffect(() => {
setIsOpen(hoverContent != null && (showHoverContent || alwaysShow));
Expand All @@ -79,7 +82,7 @@ export const WithHoverActions = React.memo<Props>(
}, [closePopOverTrigger]);

return (
<Container onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
<div onMouseLeave={onMouseLeave}>
<WithHoverActionsPopover
anchorPosition={'downCenter'}
button={content}
Expand All @@ -90,7 +93,7 @@ export const WithHoverActions = React.memo<Props>(
>
{isOpen ? <>{hoverContent}</> : null}
</WithHoverActionsPopover>
</Container>
</div>
);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('FieldName', () => {
<FieldName {...defaultProps} />
</TestProviders>
);
wrapper.find('div').at(1).simulate('mouseenter');
wrapper.find('[data-test-subj="withHoverActionsButton"]').at(0).simulate('mouseenter');
wrapper.update();
expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(true);
});
Expand Down

0 comments on commit f1ab2c6

Please sign in to comment.