vrembem 3.0.2 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2542,7 +2542,7 @@
2542
2542
  // Check if trigger or element are being hovered.
2543
2543
  var isHovered = popover.el.closest(':hover') === popover.el || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or element are being focused.
2544
2544
 
2545
- var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]"); // Close if the trigger and element are not currently hovered or focused.
2545
+ var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]"); // Close if the trigger and element are not currently hovered or focused.
2546
2546
 
2547
2547
  if (!isHovered && !isFocused) {
2548
2548
  popover.close();
@@ -2587,21 +2587,21 @@
2587
2587
  function handleDocumentClick(popover) {
2588
2588
  var root = this;
2589
2589
  document.addEventListener('click', function _f(event) {
2590
- // Check if a popover was clicked.
2591
- var result = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]");
2590
+ // Check if a popover or its trigger was clicked.
2591
+ var wasClicked = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]"); // If popover or popover trigger was clicked...
2592
2592
 
2593
- if (!result) {
2594
- // If it doesn't match and popover is open, close it and remove event listener.
2593
+ if (wasClicked) {
2594
+ // If popover element exists and is not active...
2595
+ if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
2596
+ this.removeEventListener('click', _f);
2597
+ }
2598
+ } else {
2599
+ // If popover element exists and is active...
2595
2600
  if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
2596
2601
  popover.close();
2597
2602
  }
2598
2603
 
2599
2604
  this.removeEventListener('click', _f);
2600
- } else {
2601
- // If it does match and popover isn't currently active, remove event listener.
2602
- if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
2603
- this.removeEventListener('click', _f);
2604
- }
2605
2605
  }
2606
2606
  });
2607
2607
  }