From da4bdcece6bbe746975d822a035ff4a314bea996 Mon Sep 17 00:00:00 2001 From: Segun Adebayo Date: Sat, 9 Nov 2024 11:35:59 +0000 Subject: [PATCH] refactor: treeview --- .changeset/proud-numbers-cheer.md | 5 +++++ packages/machines/tree-view/src/tree-view.connect.ts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/proud-numbers-cheer.md diff --git a/.changeset/proud-numbers-cheer.md b/.changeset/proud-numbers-cheer.md new file mode 100644 index 0000000000..3b26ddb8b6 --- /dev/null +++ b/.changeset/proud-numbers-cheer.md @@ -0,0 +1,5 @@ +--- +"@zag-js/tree-view": patch +--- + +Add `data-*` attributes to branch content diff --git a/packages/machines/tree-view/src/tree-view.connect.ts b/packages/machines/tree-view/src/tree-view.connect.ts index 5e57f9a70a..81f301c17a 100644 --- a/packages/machines/tree-view/src/tree-view.connect.ts +++ b/packages/machines/tree-view/src/tree-view.connect.ts @@ -372,6 +372,9 @@ export function connect(state: State, send: Send, normalize role: "group", dir: state.context.dir, "data-state": nodeState.expanded ? "open" : "closed", + "data-depth": nodeState.depth, + "data-path": props.indexPath.join("/"), + "data-value": nodeState.value, hidden: !nodeState.expanded, }) },