From a4003df7e8312adbc0ee9922ae7c76420b486013 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Mon, 19 Oct 2026 19:08:21 -0700
Subject: [PATCH] Enhancement (QoL): allow independently toggling child +
parent tags in WF tag fields (#14400)
---
.../workflow-edit-dialog.component.html | 3 ++-
.../common/input/tags/tags.component.spec.ts | 16 ++++++++++++++++
.../common/input/tags/tags.component.ts | 9 +++++++--
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
index 1a4592183..d10194138 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
@@ -209,6 +209,7 @@
@if (isTagsFilter(filter.get('type').value)) {
@@ -320,7 +321,7 @@
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.spec.ts b/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
index b252cecb1..728713dd7 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
+++ b/src-ui/src/app/components/common/input/tags/tags.component.spec.ts
@@ -222,6 +222,22 @@ describe('TagsComponent', () => {
expect(propagated).toEqual([2, 1])
})
+ it('should not add parents or remove children when not preserving hierarchy', () => {
+ const parent: Tag = { id: 1, name: 'parent' }
+ const child: Tag = { id: 2, name: 'child', parent: 1 }
+ parent.children = [child]
+ component.tags = [parent, child]
+ component.preserveHierarchy = false
+
+ component.value = []
+ component.addTag(2)
+ expect(component.value).toEqual([2])
+
+ component.value = [1, 2]
+ component.removeTag(1)
+ expect(component.value).toEqual([2])
+ })
+
it('should not duplicate parents when adding sibling nested tags', () => {
const root: Tag = { id: 1, name: 'root' }
const parent: Tag = { id: 2, name: 'parent', parent: 1 }
diff --git a/src-ui/src/app/components/common/input/tags/tags.component.ts b/src-ui/src/app/components/common/input/tags/tags.component.ts
index 20a489841..1410db99b 100644
--- a/src-ui/src/app/components/common/input/tags/tags.component.ts
+++ b/src-ui/src/app/components/common/input/tags/tags.component.ts
@@ -109,6 +109,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
@Input()
multiple: boolean = true
+ @Input()
+ preserveHierarchy: boolean = true
+
@Output()
filterDocuments = new EventEmitter()
@@ -148,7 +151,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
oldValue.splice(index, 1)
// remove children
- oldValue = this.removeChildren(oldValue, tag)
+ if (this.preserveHierarchy) {
+ oldValue = this.removeChildren(oldValue, tag)
+ }
this.value = [...oldValue]
this.onChange(this.value)
@@ -167,7 +172,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
}
public onAdd(tag: Tag) {
- if (tag?.parent) {
+ if (this.preserveHierarchy && tag?.parent) {
// add all parents recursively
const parent = this.getTag(tag.parent)
if (parent && !this.value.includes(parent.id)) {