mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-09-04 17:05:05 +00:00
Fix: enure emit parent tag when re-added
This commit is contained in:
@@ -207,6 +207,21 @@ describe('TagsComponent', () => {
|
||||
expect(component.value).toEqual([2, 1])
|
||||
})
|
||||
|
||||
it('should propagate parents added via ng-select selection', () => {
|
||||
const parent: Tag = { id: 1, name: 'parent' }
|
||||
const child: Tag = { id: 2, name: 'child', parent: 1 }
|
||||
component.tags = [parent, child]
|
||||
fixture.detectChanges()
|
||||
let propagated: number[]
|
||||
component.registerOnChange((value: number[]) => (propagated = value))
|
||||
|
||||
component.value = []
|
||||
component.select.select(component.select.itemsList.findItem(child.id))
|
||||
|
||||
expect(component.value).toEqual([2, 1])
|
||||
expect(propagated).toEqual([2, 1])
|
||||
})
|
||||
|
||||
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 }
|
||||
|
||||
@@ -173,6 +173,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
if (parent && !this.value.includes(parent.id)) {
|
||||
this.value = [...this.value, parent.id]
|
||||
this.onAdd(parent)
|
||||
this.onChange(this.value) // re-emit for ng-select
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user