@unabridged/midwest 0.9.0 → 0.10.0

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.
@@ -2822,7 +2822,7 @@ class Dropdown extends Controller {
2822
2822
  };
2823
2823
  get buttonEl() {
2824
2824
  return this.element.parentElement?.querySelector(
2825
- `[popovertarget="${this.element.id}"]`
2825
+ `[popovertarget="${this.element.id}"]:not([popovertargetaction="hide"])`
2826
2826
  );
2827
2827
  }
2828
2828
  get isComputed() {
@@ -2843,6 +2843,9 @@ class Dropdown extends Controller {
2843
2843
  const items = this.menuItems;
2844
2844
  if (items.length === 0)
2845
2845
  return;
2846
+ if (!["ArrowDown", "ArrowUp", "Home", "End", "Escape", "Tab"].includes(event.key))
2847
+ return;
2848
+ event.stopPropagation();
2846
2849
  const currentIndex = items.findIndex((item) => item === document.activeElement);
2847
2850
  switch (event.key) {
2848
2851
  case "ArrowDown": {
@@ -2868,7 +2871,7 @@ class Dropdown extends Controller {
2868
2871
  case "Escape":
2869
2872
  event.preventDefault();
2870
2873
  this.element.hidePopover();
2871
- this.buttonEl.focus();
2874
+ requestAnimationFrame(() => this.buttonEl?.focus());
2872
2875
  break;
2873
2876
  case "Tab":
2874
2877
  this.element.hidePopover();
@@ -2882,6 +2885,8 @@ class Dropdown extends Controller {
2882
2885
  this.element.querySelectorAll(
2883
2886
  '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])'
2884
2887
  )
2888
+ ).filter(
2889
+ (item) => item.closest('[data-controller~="midwest-dropdown"]') === this.element && getComputedStyle(item).display !== "none"
2885
2890
  );
2886
2891
  }
2887
2892
  computedCB(entries) {