]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix select option removal and pagination update (#10933)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Thu, 25 Sep 2025 07:42:43 +0000 (00:42 -0700)
committerGitHub <noreply@github.com>
Thu, 25 Sep 2025 07:42:43 +0000 (00:42 -0700)
src-ui/src/app/components/common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component.ts

index 617d825b22f1959d8f6e251928355e31dd412501..8e8bddfabe8f7775384dff5e6775e8078cf7f802 100644 (file)
@@ -177,10 +177,16 @@ export class CustomFieldEditDialogComponent
   }
 
   public removeSelectOption(index: number) {
-    this.selectOptions.removeAt(index)
-    this._allSelectOptions.splice(
-      index + (this.selectOptionsPage - 1) * SELECT_OPTION_PAGE_SIZE,
-      1
+    const globalIndex =
+      index + (this.selectOptionsPage - 1) * SELECT_OPTION_PAGE_SIZE
+    this._allSelectOptions.splice(globalIndex, 1)
+
+    const totalPages = Math.max(
+      1,
+      Math.ceil(this._allSelectOptions.length / SELECT_OPTION_PAGE_SIZE)
     )
+    const targetPage = Math.min(this.selectOptionsPage, totalPages)
+
+    this.selectOptionsPage = targetPage
   }
 }