bootstrap/js
Amit Rathiesh 13aa16a99b
Fix: Popover with hover and click triggers closes on mouseleave (#41511)
* Fix: Popover with hover and click triggers closes on mouseleave

When a popover is configured with `trigger: 'hover click'`,
if you open it by a click, it would incorrectly close when the
mouse pointer leaves the trigger element. This was because the
`mouseleave` event (part of the hover trigger) would hide the
popover without adequately respecting the click trigger's intent
to keep it open.

This commit modifies the click event listener within `Tooltip.js`
(which Popover extends) to explicitly manage the `_activeTrigger[TRIGGER_CLICK]`
state:
- When a click opens the popover or makes a hover-opened popover
  sticky, `_activeTrigger[TRIGGER_CLICK]` is set to `true`.
- When a click closes an already click-activated popover,
  `_activeTrigger[TRIGGER_CLICK]` is set to `false`.

The `_leave()` method, called by `mouseleave`, already checks
`_isWithActiveTrigger()`. With `_activeTrigger[TRIGGER_CLICK]`
now accurately reflecting the click state, `_leave()` will not
hide a click-activated popover when the mouse leaves the trigger
element. The popover will now correctly remain open until a
subsequent click closes it.

* Removed `test-popover.html`

* Fix linting issues

* Add unit test

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Julien Déramond <juderamond@gmail.com>
2025-06-03 12:19:24 -07:00
..
dist Release v5.3.6 (#41406) 2025-05-05 12:21:55 -07:00
src Fix: Popover with hover and click triggers closes on mouseleave (#41511) 2025-06-03 12:19:24 -07:00
tests Fix: Popover with hover and click triggers closes on mouseleave (#41511) 2025-06-03 12:19:24 -07:00
index.esm.js Remove version from index.{esm,umd}.js too (#38302) 2023-03-22 10:23:24 +02:00
index.umd.js Remove version from index.{esm,umd}.js too (#38302) 2023-03-22 10:23:24 +02:00