Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sour-news-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openproject/primer-view-components": patch
---

[68697] Allow deselecting tree view items in single select, when clicking on the selected item
7 changes: 3 additions & 4 deletions app/components/primer/alpha/tree_view/tree_view.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {controller, target} from '@github/catalyst'
import {SelectStrategy, SelectVariant, TreeViewSubTreeNodeElement} from './tree_view_sub_tree_node_element'

Check failure on line 2 in app/components/primer/alpha/tree_view/tree_view.ts

View workflow job for this annotation

GitHub Actions / eslint

SelectVariant not found in './tree_view_sub_tree_node_element'

Check failure on line 2 in app/components/primer/alpha/tree_view/tree_view.ts

View workflow job for this annotation

GitHub Actions / eslint

SelectStrategy not found in './tree_view_sub_tree_node_element'
import {useRovingTabIndex} from './tree_view_roving_tab_index'
import type {TreeViewCheckedValue, TreeViewNodeInfo, TreeViewNodeType} from '../../shared_events'

Expand All @@ -24,7 +24,7 @@
for (const addedNode of mutation.addedNodes) {
if (!(addedNode instanceof HTMLElement)) continue

// eslint-disable-next-line custom-elements/no-dom-traversal-in-connectedcallback

Check failure on line 27 in app/components/primer/alpha/tree_view/tree_view.ts

View workflow job for this annotation

GitHub Actions / eslint

Definition for rule 'custom-elements/no-dom-traversal-in-connectedcallback' was not found
if (addedNode.querySelector('[aria-expanded=true]')) {
this.#autoExpandFrom(addedNode)
}
Expand All @@ -47,7 +47,7 @@

const newInputs = []

// eslint-disable-next-line custom-elements/no-dom-traversal-in-connectedcallback

Check failure on line 50 in app/components/primer/alpha/tree_view/tree_view.ts

View workflow job for this annotation

GitHub Actions / eslint

Definition for rule 'custom-elements/no-dom-traversal-in-connectedcallback' was not found
for (const node of this.querySelectorAll('[role=treeitem][aria-checked=true]')) {
const newInput = this.formInputPrototype.cloneNode() as HTMLInputElement
newInput.removeAttribute('data-target')
Expand Down Expand Up @@ -206,10 +206,9 @@

if (!checkSuccess) return

const currentlyChecked = !this.getNodeCheckedValue(node)

// disallow unchecking checked item in single-select mode
if (!currentlyChecked) {
if (this.getNodeCheckedValue(node) === 'true') {
this.setNodeCheckedValue(node, 'false')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have preferred this.uncheckAtPath(path)

} else {
this.checkOnlyAtPath(path)
}

Expand Down
Loading