Skip to content

Commit

Permalink
fix(tree): allow input events
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Jun 27, 2024
1 parent 1441d06 commit 0188938
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/loud-apes-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/tree-view": patch
---

Fix issue where inputs could not be used within tree
4 changes: 3 additions & 1 deletion packages/machines/tree-view/src/tree-view.connect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getEventKey, isModifierKey, type EventKeyMap } from "@zag-js/dom-event"
import { contains, dataAttr, getEventTarget, isComposingEvent } from "@zag-js/dom-query"
import { contains, dataAttr, getEventTarget, isComposingEvent, isEditableElement } from "@zag-js/dom-query"
import type { NormalizeProps, PropTypes } from "@zag-js/types"
import { parts } from "./tree-view.anatomy"
import { dom } from "./tree-view.dom"
Expand Down Expand Up @@ -106,6 +106,8 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
if (isComposingEvent(event)) return

const target = getEventTarget<HTMLElement>(event)
// allow typing in input elements within the tree
if (isEditableElement(target)) return

const node = target?.closest<HTMLElement>("[role=treeitem]")
if (!node) return
Expand Down

0 comments on commit 0188938

Please sign in to comment.