Skip to content

Commit 7b7b1bd

Browse files
committed
fix: register Show Panel click handler on window, not document
driver.js registers capture-phase click handlers on document that call stopImmediatePropagation() for all clicks inside the popover wrapper. By registering our handler on window instead of document, it fires before any document-level handlers in the capture phase (window → document → ... → target), guaranteeing we intercept the click first. Made-with: Cursor
1 parent 08e2d77 commit 7b7b1bd

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

flexfoil-ui/src/onboarding/OnboardingProvider.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,8 @@ export function OnboardingProvider({ children }: OnboardingProviderProps) {
314314
}, [clearChallengePolling, buildChallengeHTML, openPanel]);
315315

316316
// Delegated click handler for "Show Panel" buttons injected into tour popovers.
317-
// MUST register before driver.js's own capture-phase handler (which calls
318-
// stopImmediatePropagation on all popover clicks). We use a ref for openPanel
319-
// so this effect only re-runs on isActive change, keeping our listener first.
317+
// Registered on `window` (not document) in capture phase so it fires BEFORE
318+
// driver.js's document-level capture handlers which call stopImmediatePropagation.
320319
useEffect(() => {
321320
if (!isActive) return;
322321

@@ -333,8 +332,8 @@ export function OnboardingProvider({ children }: OnboardingProviderProps) {
333332
}
334333
};
335334

336-
document.addEventListener('click', handleShowPanel, true);
337-
return () => document.removeEventListener('click', handleShowPanel, true);
335+
window.addEventListener('click', handleShowPanel, true);
336+
return () => window.removeEventListener('click', handleShowPanel, true);
338337
}, [isActive]);
339338

340339
// Cleanup on unmount

0 commit comments

Comments
 (0)