Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,20 @@ describe('InlineDropdown', () => {
expect(queryByTestId('inline-dropdown-toolbar')).toBeInTheDocument();
});

it('does not close toolbar when clicking the page scrollbar (documentElement)', async () => {
const { queryByTestId } = render(<InlineDropdown {...defaultProps} selected={true} />);

await waitFor(() => {
expect(queryByTestId('inline-dropdown-toolbar')).toBeInTheDocument();
});

fireEvent.mouseDown(document.documentElement);

await waitFor(() => {
expect(queryByTestId('inline-dropdown-toolbar')).toBeInTheDocument();
});
});

it('renders delete control on portaled custom toolbar when container el is set', async () => {
const { findByLabelText } = render(<InlineDropdown {...defaultProps} selected />);
expect(await findByLabelText('Delete')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ const InlineDropdown = (props) => {
}
}, [editor, node, selected]);



const isScrollbarClicked = (event) =>
event.clientX > document.documentElement.clientWidth ||
event.clientY > document.documentElement.clientHeight ||
event.target === document.documentElement;


useEffect(() => {
// Calculate position relative to selection
const bodyRect = document.body.getBoundingClientRect();
Expand All @@ -105,6 +113,10 @@ const InlineDropdown = (props) => {
});

const handleClickOutside = (event) => {

if( isScrollbarClicked(event) ) {
return;
}
const insideSomeEditor = event.target.closest('[data-toolbar-for]');

if (
Expand Down
Loading