@@ -86,24 +86,19 @@ const initPopover = event => {
8686 return
8787 }
8888
89- // Prevent default for click events to avoid navigation
89+ // Prevent default for click events to avoid navigation (e.g. <a href="#">)
9090 if ( event . type === 'click' ) {
9191 event . preventDefault ( )
9292 }
9393
94- // Get or create instance
95- const popover = Popover . getOrCreateInstance ( target )
96-
97- // Trigger the appropriate action based on event type
98- if ( event . type === 'click' ) {
99- popover . toggle ( )
100- } else if ( event . type === 'focusin' ) {
101- popover . _activeTrigger . focus = true
102- popover . _enter ( )
103- }
94+ // Lazily create the instance. The instance's own `_setListeners()` registers
95+ // the appropriate listeners on the element for the configured triggers
96+ // (click/focus/hover), so we don't toggle or call `_enter` here — doing so
97+ // would duplicate handlers and leave stale state on `_activeTrigger`.
98+ Popover . getOrCreateInstance ( target )
10499}
105100
106- // Support click (default) , hover, and focus triggers
101+ // Auto-initialize popovers on first interaction for click , hover, and focus triggers
107102EventHandler . on ( document , EVENT_CLICK , SELECTOR_DATA_TOGGLE , initPopover )
108103EventHandler . on ( document , EVENT_FOCUSIN , SELECTOR_DATA_TOGGLE , initPopover )
109104EventHandler . on ( document , EVENT_MOUSEENTER , SELECTOR_DATA_TOGGLE , initPopover )
0 commit comments