vrembem 3.0.3 → 3.0.4

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.
@@ -2537,7 +2537,7 @@ function closeCheck(popover) {
2537
2537
  // Check if trigger or element are being hovered.
2538
2538
  var isHovered = popover.el.closest(':hover') === popover.el || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or element are being focused.
2539
2539
 
2540
- var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]"); // Close if the trigger and element are not currently hovered or focused.
2540
+ 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.
2541
2541
 
2542
2542
  if (!isHovered && !isFocused) {
2543
2543
  popover.close();
@@ -2582,21 +2582,21 @@ function handleKeydown(event) {
2582
2582
  function handleDocumentClick(popover) {
2583
2583
  var root = this;
2584
2584
  document.addEventListener('click', function _f(event) {
2585
- // Check if a popover was clicked.
2586
- var result = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]");
2585
+ // Check if a popover or its trigger was clicked.
2586
+ var wasClicked = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]"); // If popover or popover trigger was clicked...
2587
2587
 
2588
- if (!result) {
2589
- // If it doesn't match and popover is open, close it and remove event listener.
2588
+ if (wasClicked) {
2589
+ // If popover element exists and is not active...
2590
+ if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
2591
+ this.removeEventListener('click', _f);
2592
+ }
2593
+ } else {
2594
+ // If popover element exists and is active...
2590
2595
  if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
2591
2596
  popover.close();
2592
2597
  }
2593
2598
 
2594
2599
  this.removeEventListener('click', _f);
2595
- } else {
2596
- // If it does match and popover isn't currently active, remove event listener.
2597
- if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
2598
- this.removeEventListener('click', _f);
2599
- }
2600
2600
  }
2601
2601
  });
2602
2602
  }