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.
@@ -1899,7 +1899,7 @@ function closeCheck(popover) {
1899
1899
  // Check if trigger or element are being hovered.
1900
1900
  const isHovered = popover.el.closest(':hover') === popover.el || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or element are being focused.
1901
1901
 
1902
- const isFocused = document.activeElement.closest(`#${popover.id}, [aria-controls="${popover.id}"]`); // Close if the trigger and element are not currently hovered or focused.
1902
+ const 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.
1903
1903
 
1904
1904
  if (!isHovered && !isFocused) {
1905
1905
  popover.close();
@@ -1942,21 +1942,21 @@ function handleKeydown(event) {
1942
1942
  function handleDocumentClick(popover) {
1943
1943
  const root = this;
1944
1944
  document.addEventListener('click', function _f(event) {
1945
- // Check if a popover was clicked.
1946
- const result = event.target.closest(`#${popover.id}, [aria-controls="${popover.id}"]`);
1945
+ // Check if a popover or its trigger was clicked.
1946
+ const wasClicked = event.target.closest(`#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`); // If popover or popover trigger was clicked...
1947
1947
 
1948
- if (!result) {
1949
- // If it doesn't match and popover is open, close it and remove event listener.
1948
+ if (wasClicked) {
1949
+ // If popover element exists and is not active...
1950
+ if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
1951
+ this.removeEventListener('click', _f);
1952
+ }
1953
+ } else {
1954
+ // If popover element exists and is active...
1950
1955
  if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
1951
1956
  popover.close();
1952
1957
  }
1953
1958
 
1954
1959
  this.removeEventListener('click', _f);
1955
- } else {
1956
- // If it does match and popover isn't currently active, remove event listener.
1957
- if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
1958
- this.removeEventListener('click', _f);
1959
- }
1960
1960
  }
1961
1961
  });
1962
1962
  }