From 60319c6d3709718e4d079ca7cd7ebf1394d3422a Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 9 Mar 2026 19:32:46 -0700 Subject: [PATCH 1/7] Fix: prevent stale db filename during workflow actions (#12289) --- src/documents/signals/handlers.py | 2 + src/documents/tests/test_workflows.py | 58 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index 591d235bd..5be8855e6 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -833,6 +833,8 @@ def run_workflows( if not use_overrides: # limit title to 128 characters document.title = document.title[:128] + # Make sure the filename and archive filename are accurate + document.refresh_from_db(fields=["filename", "archive_filename"]) # save first before setting tags document.save() document.tags.set(doc_tag_ids) diff --git a/src/documents/tests/test_workflows.py b/src/documents/tests/test_workflows.py index deb40a165..ba1e72e1f 100644 --- a/src/documents/tests/test_workflows.py +++ b/src/documents/tests/test_workflows.py @@ -25,6 +25,7 @@ from rest_framework.test import APIClient from rest_framework.test import APITestCase from documents.file_handling import create_source_path_directory +from documents.file_handling import generate_filename from documents.file_handling import generate_unique_filename from documents.signals.handlers import run_workflows from documents.workflows.webhooks import send_webhook @@ -898,6 +899,63 @@ class TestWorkflows( expected_str = f"Document matched {trigger} from {w}" self.assertIn(expected_str, cm.output[0]) + def test_workflow_assign_custom_field_keeps_storage_filename_in_sync(self) -> None: + """ + GIVEN: + - Existing document with a storage path template that depends on a custom field + - Existing workflow triggered on document update assigning that custom field + WHEN: + - Workflow runs for the document + THEN: + - The database filename remains aligned with the moved file on disk + """ + storage_path = StoragePath.objects.create( + name="workflow-custom-field-path", + path="{{ custom_fields|get_cf_value('Custom Field 1', 'none') }}/{{ title }}", + ) + doc = Document.objects.create( + title="workflow custom field sync", + mime_type="application/pdf", + checksum="workflow-custom-field-sync", + storage_path=storage_path, + original_filename="workflow-custom-field-sync.pdf", + ) + CustomFieldInstance.objects.create( + document=doc, + field=self.cf1, + value_text="initial", + ) + + generated = generate_unique_filename(doc) + destination = (settings.ORIGINALS_DIR / generated).resolve() + create_source_path_directory(destination) + shutil.copy(self.SAMPLE_DIR / "simple.pdf", destination) + Document.objects.filter(pk=doc.pk).update(filename=generated.as_posix()) + doc.refresh_from_db() + + trigger = WorkflowTrigger.objects.create( + type=WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED, + ) + action = WorkflowAction.objects.create( + type=WorkflowAction.WorkflowActionType.ASSIGNMENT, + assign_custom_fields_values={self.cf1.pk: "cars"}, + ) + action.assign_custom_fields.add(self.cf1.pk) + workflow = Workflow.objects.create( + name="Workflow custom field filename sync", + order=0, + ) + workflow.triggers.add(trigger) + workflow.actions.add(action) + workflow.save() + + run_workflows(WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED, doc) + + doc.refresh_from_db() + expected_filename = generate_filename(doc) + self.assertEqual(Path(doc.filename), expected_filename) + self.assertTrue(doc.source_path.is_file()) + def test_document_added_workflow(self): trigger = WorkflowTrigger.objects.create( type=WorkflowTrigger.WorkflowTriggerType.DOCUMENT_ADDED, From ba0a80a8ad04e9dc2e1ae1d83d556c2a2d2f629c Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 11 Mar 2026 07:39:32 -0700 Subject: [PATCH 2/7] Fix: prevent wrapping with larger amounts of tags on small cards, reset moreTags setting to correct count (#12302) --- .../document-card-small.component.html | 2 +- .../document-card-small.component.scss | 10 ++++++++++ .../document-card-small.component.spec.ts | 10 ++++++++++ .../document-card-small.component.ts | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index b154324c7..b3a29aed4 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -15,7 +15,7 @@ } @if (document && displayFields?.includes(DisplayField.TAGS)) { -
+
@for (tagID of tagIDs; track tagID) { } diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss index 508c5251a..dce77802e 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.scss @@ -72,4 +72,14 @@ a { max-width: 80%; row-gap: .2rem; line-height: 1; + + &.tags-no-wrap { + ::ng-deep .badge { + display: inline-block; + max-width: 100%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } } diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts index 63cfc5a50..982b3980b 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts @@ -82,6 +82,16 @@ describe('DocumentCardSmallComponent', () => { ).toHaveLength(6) }) + it('should clear hidden tag counter when tag count falls below the limit', () => { + expect(component.moreTags).toEqual(3) + + component.document.tags = [1, 2, 3, 4, 5, 6] + fixture.detectChanges() + + expect(component.moreTags).toBeNull() + expect(fixture.nativeElement.textContent).not.toContain('+ 3') + }) + it('should try to close the preview on mouse leave', () => { component.popupPreview = { close: jest.fn(), diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts index ad428dfab..05f84d752 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts @@ -126,6 +126,7 @@ export class DocumentCardSmallComponent this.moreTags = this.document.tags.length - (limit - 1) return this.document.tags.slice(0, limit - 1) } else { + this.moreTags = null return this.document.tags } } From d919c341b12ba1fcc2a3f9bc84b4e98160582990 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:57:35 -0700 Subject: [PATCH 3/7] Fix: clear descendant selections in dropdown when parent toggled (#12326) --- .../filterable-dropdown.component.spec.ts | 53 +++++++++++++++++++ .../filterable-dropdown.component.ts | 35 ++++++++++++ 2 files changed, 88 insertions(+) diff --git a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts index 2ecf95f2b..1763239b1 100644 --- a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts +++ b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts @@ -631,6 +631,59 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () => ]) }) + it('deselecting a parent clears selected descendants', () => { + const root: Tag = { id: 100, name: 'Root Tag' } + const child: Tag = { id: 101, name: 'Child Tag', parent: root.id } + const grandchild: Tag = { + id: 102, + name: 'Grandchild Tag', + parent: child.id, + } + const other: Tag = { id: 103, name: 'Other Tag' } + + selectionModel.items = [root, child, grandchild, other] + selectionModel.set(root.id, ToggleableItemState.Selected, false) + selectionModel.set(child.id, ToggleableItemState.Selected, false) + selectionModel.set(grandchild.id, ToggleableItemState.Selected, false) + selectionModel.set(other.id, ToggleableItemState.Selected, false) + + selectionModel.toggle(root.id, false) + + expect(selectionModel.getSelectedItems()).toEqual([other]) + }) + + it('un-excluding a parent clears excluded descendants', () => { + const root: Tag = { id: 110, name: 'Root Tag' } + const child: Tag = { id: 111, name: 'Child Tag', parent: root.id } + const other: Tag = { id: 112, name: 'Other Tag' } + + selectionModel.items = [root, child, other] + selectionModel.set(root.id, ToggleableItemState.Excluded, false) + selectionModel.set(child.id, ToggleableItemState.Excluded, false) + selectionModel.set(other.id, ToggleableItemState.Excluded, false) + + selectionModel.exclude(root.id, false) + + expect(selectionModel.getExcludedItems()).toEqual([other]) + }) + + it('excluding a selected parent clears selected descendants', () => { + const root: Tag = { id: 120, name: 'Root Tag' } + const child: Tag = { id: 121, name: 'Child Tag', parent: root.id } + const other: Tag = { id: 122, name: 'Other Tag' } + + selectionModel.manyToOne = true + selectionModel.items = [root, child, other] + selectionModel.set(root.id, ToggleableItemState.Selected, false) + selectionModel.set(child.id, ToggleableItemState.Selected, false) + selectionModel.set(other.id, ToggleableItemState.Selected, false) + + selectionModel.exclude(root.id, false) + + expect(selectionModel.getExcludedItems()).toEqual([root]) + expect(selectionModel.getSelectedItems()).toEqual([other]) + }) + it('resorts items immediately when document count sorting enabled', () => { const apple: Tag = { id: 55, name: 'Apple' } const zebra: Tag = { id: 56, name: 'Zebra' } diff --git a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts index ec5425630..bc15e3374 100644 --- a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts +++ b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts @@ -231,6 +231,7 @@ export class FilterableDropdownSelectionModel { state == ToggleableItemState.Excluded ) { this.temporarySelectionStates.delete(id) + this.clearDescendantSelections(id) } if (!id) { @@ -257,6 +258,7 @@ export class FilterableDropdownSelectionModel { if (this.manyToOne || this.singleSelect) { this.temporarySelectionStates.set(id, ToggleableItemState.Excluded) + this.clearDescendantSelections(id) if (this.singleSelect) { for (let key of this.temporarySelectionStates.keys()) { @@ -277,9 +279,15 @@ export class FilterableDropdownSelectionModel { newState = ToggleableItemState.NotSelected } this.temporarySelectionStates.set(id, newState) + if (newState == ToggleableItemState.Excluded) { + this.clearDescendantSelections(id) + } } } else if (!id || state == ToggleableItemState.Excluded) { this.temporarySelectionStates.delete(id) + if (id) { + this.clearDescendantSelections(id) + } } if (fireEvent) { @@ -291,6 +299,33 @@ export class FilterableDropdownSelectionModel { return this.selectionStates.get(id) || ToggleableItemState.NotSelected } + private clearDescendantSelections(id: number) { + for (const descendantID of this.getDescendantIDs(id)) { + this.temporarySelectionStates.delete(descendantID) + } + } + + private getDescendantIDs(id: number): number[] { + const descendants: number[] = [] + const queue: number[] = [id] + + while (queue.length) { + const parentID = queue.shift() + for (const item of this._items) { + if ( + typeof item?.id === 'number' && + typeof (item as any)['parent'] === 'number' && + (item as any)['parent'] === parentID + ) { + descendants.push(item.id) + queue.push(item.id) + } + } + } + + return descendants + } + get logicalOperator(): LogicalOperator { return this.temporaryLogicalOperator } From 40255cfdbb8cf12c38df01a507b01e3f4991a697 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 12 Mar 2026 14:06:16 -0700 Subject: [PATCH 4/7] Fix: correct dropdown list active color in dark mode (#12328) --- src-ui/src/theme.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src-ui/src/theme.scss b/src-ui/src/theme.scss index eacc3b4e7..e6a4ea113 100644 --- a/src-ui/src/theme.scss +++ b/src-ui/src/theme.scss @@ -149,6 +149,10 @@ $form-check-radio-checked-bg-image-dark: url("data:image/svg+xml, Date: Sun, 15 Mar 2026 18:47:18 -0700 Subject: [PATCH 7/7] Documentation: Add v2.20.11 changelog (#12356) * Changelog v2.20.11 - GHA * Update changelog for version 2.20.11 Added security advisory and fixed dropdown list issues. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> --- docs/changelog.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 404e6d355..ec2342060 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,29 @@ # Changelog +## paperless-ngx 2.20.11 + +### Security + +- Resolve [GHSA-59xh-5vwx-4c4q](https://github.com/paperless-ngx/paperless-ngx/security/advisories/GHSA-59xh-5vwx-4c4q) + +### Bug Fixes + +- Fix: correct dropdown list active color in dark mode [@shamoon](https://github.com/shamoon) ([#12328](https://github.com/paperless-ngx/paperless-ngx/pull/12328)) +- Fixhancement: clear descendant selections in dropdown when parent toggled [@shamoon](https://github.com/shamoon) ([#12326](https://github.com/paperless-ngx/paperless-ngx/pull/12326)) +- Fix: prevent wrapping with larger amounts of tags on small cards, reset moreTags setting to correct count [@shamoon](https://github.com/shamoon) ([#12302](https://github.com/paperless-ngx/paperless-ngx/pull/12302)) +- Fix: prevent stale db filename during workflow actions [@shamoon](https://github.com/shamoon) ([#12289](https://github.com/paperless-ngx/paperless-ngx/pull/12289)) + +### All App Changes + +
+4 changes + +- Fix: correct dropdown list active color in dark mode [@shamoon](https://github.com/shamoon) ([#12328](https://github.com/paperless-ngx/paperless-ngx/pull/12328)) +- Fixhancement: clear descendant selections in dropdown when parent toggled [@shamoon](https://github.com/shamoon) ([#12326](https://github.com/paperless-ngx/paperless-ngx/pull/12326)) +- Fix: prevent wrapping with larger amounts of tags on small cards, reset moreTags setting to correct count [@shamoon](https://github.com/shamoon) ([#12302](https://github.com/paperless-ngx/paperless-ngx/pull/12302)) +- Fix: prevent stale db filename during workflow actions [@shamoon](https://github.com/shamoon) ([#12289](https://github.com/paperless-ngx/paperless-ngx/pull/12289)) +
+ ## paperless-ngx 2.20.10 ### Bug Fixes