Skip to content

Commit 5ec48b5

Browse files
committed
fix: intercept all pointer events on Show Panel button, not just click
driver.js registers capture-phase handlers on document for pointerdown, mousedown, pointerup, mouseup AND click. All call stopImmediatePropagation. We now intercept all five event types on window capture phase to fully own the event chain for [data-open-panel] button interactions. Made-with: Cursor
1 parent 7b7b1bd commit 5ec48b5

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

flexfoil-ui/src/onboarding/OnboardingProvider.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,12 @@ export function OnboardingProvider({ children }: OnboardingProviderProps) {
316316
// Delegated click handler for "Show Panel" buttons injected into tour popovers.
317317
// Registered on `window` (not document) in capture phase so it fires BEFORE
318318
// driver.js's document-level capture handlers which call stopImmediatePropagation.
319+
// Also intercepts pointerdown to prevent driver.js from killing the pointer
320+
// event chain before click can fire.
319321
useEffect(() => {
320322
if (!isActive) return;
321323

322-
const handleShowPanel = (e: MouseEvent) => {
324+
const handleShowPanelClick = (e: Event) => {
323325
const btn = (e.target as HTMLElement).closest<HTMLButtonElement>('[data-open-panel]');
324326
if (!btn) return;
325327
e.stopPropagation();
@@ -332,8 +334,25 @@ export function OnboardingProvider({ children }: OnboardingProviderProps) {
332334
}
333335
};
334336

335-
window.addEventListener('click', handleShowPanel, true);
336-
return () => window.removeEventListener('click', handleShowPanel, true);
337+
const eatPointerOnBtn = (e: Event) => {
338+
const btn = (e.target as HTMLElement).closest?.('[data-open-panel]');
339+
if (!btn) return;
340+
e.stopPropagation();
341+
e.stopImmediatePropagation();
342+
};
343+
344+
window.addEventListener('click', handleShowPanelClick, true);
345+
window.addEventListener('pointerdown', eatPointerOnBtn, true);
346+
window.addEventListener('pointerup', eatPointerOnBtn, true);
347+
window.addEventListener('mousedown', eatPointerOnBtn, true);
348+
window.addEventListener('mouseup', eatPointerOnBtn, true);
349+
return () => {
350+
window.removeEventListener('click', handleShowPanelClick, true);
351+
window.removeEventListener('pointerdown', eatPointerOnBtn, true);
352+
window.removeEventListener('pointerup', eatPointerOnBtn, true);
353+
window.removeEventListener('mousedown', eatPointerOnBtn, true);
354+
window.removeEventListener('mouseup', eatPointerOnBtn, true);
355+
};
337356
}, [isActive]);
338357

339358
// Cleanup on unmount

0 commit comments

Comments
 (0)