From e4d5e3457bc6750f1dfc2585ed67f4ffa4ff8c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20P=C3=B6ttker?= Date: Fri, 8 May 2026 12:29:27 +0200 Subject: [PATCH] refactor: simplify LabelElementRow rendering by replacing Form.Item shouldUpdate with Form.useWatch --- paperless-frontend/src/pages/SettingsPage.tsx | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/paperless-frontend/src/pages/SettingsPage.tsx b/paperless-frontend/src/pages/SettingsPage.tsx index be81853..eaf93aa 100644 --- a/paperless-frontend/src/pages/SettingsPage.tsx +++ b/paperless-frontend/src/pages/SettingsPage.tsx @@ -11,6 +11,7 @@ import { QrcodeOutlined, UnorderedListOutlined, PrinterOutlined, } from '@ant-design/icons'; import type { ColumnsType } from 'antd/es/table'; +import type { FormInstance } from 'antd'; import { settingsApi, type SettingDocType, type SettingPostprocessing, type SettingUserClient, @@ -1781,7 +1782,9 @@ function InboxActionsForTemplateEditor({ templateId }: { templateId: number }) { // Eingangsdokumentarten Tab (ehemals Barcode-Vorlagen) // ═══════════════════════════════════════════════════════════════════ -function LabelElementRow({ listName, remove }: { listName: number; remove: (n: number) => void }) { +function LabelElementRow({ form, listName, remove }: { form: FormInstance; listName: number; remove: (n: number) => void }) { + const type = Form.useWatch(['LabelLayout', listName, 'type'], form); + return ( - - {({ getFieldValue }) => { - const type = getFieldValue(['LabelLayout', listName, 'type']); - if (type === 'text') return ( - - - - - - - - - - ); - if (type === 'qr') return ( - - - - - - - ); - if (type === 'line') return ( - - - - - - - - ); - return null; - }} - + + {type === 'text' && ( + + + + + + + + + + )} + + {type === 'qr' && ( + + + + + + + )} + + {type === 'line' && ( + + + + + + + + )} ); } @@ -2161,7 +2161,7 @@ function BarcodeTemplatesTab() { {(layoutFields, { add: addEl, remove: removeEl }) => ( <> {layoutFields.map(({ key, name: elName }) => ( - + ))}