Skip to content

Commit 9abda80

Browse files
committed
simplify the code
1 parent d8d34c3 commit 9abda80

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

app/components/primer/alpha/tree_view/tree_view.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export class TreeViewElement extends HTMLElement {
193193
// behavior for these element types is user- or browser-defined
194194
if (!(node instanceof HTMLDivElement)) return
195195

196+
const path = this.getNodePath(node)
196197
const nodeInfo = this.infoFromNode(node, 'true')
197198

198199
const checkSuccess = this.dispatchEvent(
@@ -205,17 +206,10 @@ export class TreeViewElement extends HTMLElement {
205206

206207
if (!checkSuccess) return
207208

208-
const currentlyChecked = this.getNodeCheckedValue(node) === 'true'
209-
210-
if (currentlyChecked) {
209+
if (this.getNodeCheckedValue(node) === 'true') {
211210
this.setNodeCheckedValue(node, 'false')
212211
} else {
213-
// Uncheck all other nodes first
214-
for (const el of this.activeNodes) {
215-
this.uncheckAtPath(this.getNodePath(el))
216-
}
217-
218-
this.setNodeCheckedValue(node, 'true')
212+
this.checkOnlyAtPath(path);
219213
}
220214

221215
this.dispatchEvent(

0 commit comments

Comments
 (0)