bits-ui 2.8.9 → 2.8.10

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.
@@ -41,6 +41,12 @@
41
41
  function handleInteractOutside(e: PointerEvent) {
42
42
  onInteractOutside(e);
43
43
  if (e.defaultPrevented) return;
44
+
45
+ // don't close if the interaction is with a submenu content or items
46
+ if (e.target && e.target instanceof Element) {
47
+ const subContentSelector = `[${contentState.parentMenu.root.getBitsAttr("sub-content")}]`;
48
+ if (e.target.closest(subContentSelector)) return;
49
+ }
44
50
  contentState.parentMenu.onClose();
45
51
  }
46
52
 
@@ -41,6 +41,12 @@
41
41
  if (e.defaultPrevented) return;
42
42
  onInteractOutside(e);
43
43
  if (e.defaultPrevented) return;
44
+
45
+ // don't close if the interaction is with a submenu content or items
46
+ if (e.target && e.target instanceof Element) {
47
+ const subContentSelector = `[${contentState.parentMenu.root.getBitsAttr("sub-content")}]`;
48
+ if (e.target.closest(subContentSelector)) return;
49
+ }
44
50
  contentState.parentMenu.onClose();
45
51
  }
46
52
  function handleEscapeKeydown(e: KeyboardEvent) {
@@ -42,6 +42,11 @@
42
42
  function handleInteractOutside(e: PointerEvent) {
43
43
  onInteractOutside(e);
44
44
  if (e.defaultPrevented) return;
45
+ // don't close if the interaction is with a submenu content or items
46
+ if (e.target && e.target instanceof Element) {
47
+ const subContentSelector = `[${contentState.parentMenu.root.getBitsAttr("sub-content")}]`;
48
+ if (e.target.closest(subContentSelector)) return;
49
+ }
45
50
  contentState.parentMenu.onClose();
46
51
  }
47
52
 
@@ -423,15 +423,13 @@ export class MenuItemState {
423
423
  return;
424
424
  const selectEvent = new CustomEvent("menuitemselect", { bubbles: true, cancelable: true });
425
425
  this.opts.onSelect.current(selectEvent);
426
- afterTick(() => {
427
- if (selectEvent.defaultPrevented) {
428
- this.item.content.parentMenu.root.isUsingKeyboard.current = false;
429
- return;
430
- }
431
- if (this.opts.closeOnSelect.current) {
432
- this.item.content.parentMenu.root.opts.onClose();
433
- }
434
- });
426
+ if (selectEvent.defaultPrevented) {
427
+ this.item.content.parentMenu.root.isUsingKeyboard.current = false;
428
+ return;
429
+ }
430
+ if (this.opts.closeOnSelect.current) {
431
+ this.item.content.parentMenu.root.opts.onClose();
432
+ }
435
433
  }
436
434
  onkeydown(e) {
437
435
  const isTypingAhead = this.item.content.search !== "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "2.8.9",
3
+ "version": "2.8.10",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",