From 90e621774943bef451382662f936511ba1bf0b75 Mon Sep 17 00:00:00 2001 From: iYuan Date: Sat, 13 Jun 2026 00:38:01 +0800 Subject: [PATCH] fix(inbound): preserve custom share strategy on edit (#5225) --- .../pages/inbounds/form/InboundFormModal.tsx | 3 +- frontend/src/test/inbound-form-modal.test.tsx | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/inbounds/form/InboundFormModal.tsx b/frontend/src/pages/inbounds/form/InboundFormModal.tsx index 6d238f5e6..2b71d05d2 100644 --- a/frontend/src/pages/inbounds/form/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/form/InboundFormModal.tsx @@ -381,7 +381,8 @@ export default function InboundFormModal({ // protocol reset drops a nodeId that no longer applies. useEffect(() => { if (!open) return; - if (!nodeShareOptionAvailable && shareAddrStrategy === 'node') { + const current = form.getFieldValue('shareAddrStrategy') as InboundFormValues['shareAddrStrategy'] | undefined; + if (!nodeShareOptionAvailable && (current ?? 'node') === 'node') { form.setFieldValue('shareAddrStrategy', 'listen'); } // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/frontend/src/test/inbound-form-modal.test.tsx b/frontend/src/test/inbound-form-modal.test.tsx index 534aa4e6f..8738595e4 100644 --- a/frontend/src/test/inbound-form-modal.test.tsx +++ b/frontend/src/test/inbound-form-modal.test.tsx @@ -1,6 +1,8 @@ import { describe, it, expect } from 'vitest'; +import { screen } from '@testing-library/react'; import InboundFormModal from '@/pages/inbounds/form/InboundFormModal'; +import { DBInbound } from '@/models/dbinbound'; import { renderWithProviders, fieldLabels, @@ -38,4 +40,39 @@ describe('InboundFormModal', () => { expect(fieldLabels()).toMatchSnapshot(proto); } }); + + it('preserves custom share address strategy when editing a local inbound', async () => { + renderWithProviders( + {}} + onSaved={() => {}} + />, + ); + + const shareAddrInput = await screen.findByDisplayValue('edge.example.test'); + expect((shareAddrInput as HTMLInputElement).value).toBe('edge.example.test'); + }); });