Skip to content

Commit 8a93fb5

Browse files
committed
fix(editable-html-tip-tap): prevent toolbar closing when clicking the page scrollbar inline-dropdown PIE-575
1 parent 0f9838f commit 8a93fb5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/editable-html-tip-tap/src/components/respArea/InlineDropdown.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ const InlineDropdown = (props) => {
9393
}
9494
}, [editor, node, selected]);
9595

96+
97+
const isScrollbarClicked = (event) => event.clientX >= document.documentElement.clientWidth ||
98+
event.clientY >= document.documentElement.clientHeight ||
99+
// macOS overlay: target is document.documentElement or document.body directly
100+
// when clicking the window scrollbar — never a child element
101+
(
102+
(event.target === document.documentElement || event.target === document.body) &&
103+
// within 20px of the right or bottom edge of the viewport
104+
(event.clientX >= window.innerWidth - 20 || event.clientY >= window.innerHeight - 20)
105+
);
106+
107+
96108
useEffect(() => {
97109
// Calculate position relative to selection
98110
const bodyRect = document.body.getBoundingClientRect();
@@ -105,6 +117,10 @@ const InlineDropdown = (props) => {
105117
});
106118

107119
const handleClickOutside = (event) => {
120+
121+
if( isScrollbarClicked(event) ) {
122+
return;
123+
}
108124
const insideSomeEditor = event.target.closest('[data-toolbar-for]');
109125

110126
if (

0 commit comments

Comments
 (0)