Skip to content

refactor(web): network connection form UX (part 3) #3349

Merged
dgdavid merged 5 commits intoenhance-network-connection-formfrom
network-tanstack-form-part3
Mar 31, 2026
Merged

refactor(web): network connection form UX (part 3) #3349
dgdavid merged 5 commits intoenhance-network-connection-formfrom
network-tanstack-form-part3

Conversation

@dgdavid
Copy link
Copy Markdown
Contributor

@dgdavid dgdavid commented Mar 31, 2026

This PR continues the network connection form reimplementation, built on top of #3338. It introduces a reusable array input component, wires it into the form for addresses, DNS servers, and DNS search domains, and adds comprehensive client-side validation.

ArrayField component

A new ArrayField component handles list-valued fields. It accepts multiple entries via a text input, , one at a time, and displays them as editable/removable PF/Label. It also supports pasting multiple values at once and the ability to optionally skip duplicated entries. The component is registered in AppField alongside previous added ChoiceField (which probably deserves a better name).

Addresses, DNS servers, and DNS search domains

All three field types now use ArrayField with per-entry format validation: IPv4 and IPv6 addresses accept optional CIDR notation, DNS servers accept bare IPv4 or IPv6, and DNS search domains follow RFC 952/1123 label rules.

Client-side validation

Validation runs on submission rather than on each keystroke or focus change, so users are not interrupted while filling in the form. All rules live in a single validateConnectionForm helper:

  • name is required
  • addresses are required in manual mode and must all be valid when given
  • gateways are validated only when present and mode manual, ignored if mode auto and no IP address (optional in that mode) is given
  • DNS and search domain lists must have at least one valid entry when their toggle is on.

IPv4 validation was also tightened to require standard four-part decimal notation, rejecting values like 1111 that the underlying library would otherwise accept.

A secondary fix ensures re-submission works after a failed attempt: TanStack Form keeps canSubmit false once field errors are set by onSubmitAsync, since there are no per-field validators to clear them. The form now resets field error
maps before each attempt.


Two example of the form in action. The form has several other states worth exploring it by yourself. The easiest way is to check out the branch and play with it.

Without validation errors With validation errors
localhost_8080_ (22) localhost_8080_ (23)

There is known, small UI caveat: repeated error icon in Name field. Something that will be addressed in subsequent PR, after all other important stuff like edition mode is re-implemented.


What is deferred to follow-up PRs

  • Auto-generated connection name.
  • Edit mode.
  • Type-specific subforms (bond, bridge, VLAN).

Notes for reviewers

Changelog entry postponed for the final PR from the feature branch against master.

dgdavid added 5 commits March 30, 2026 22:45
A form field for entering and managing a list of string values.

Supports per-entry validation, duplicate skipping, paste, and keyboard
navigation between entries.
…ains

Replaces the free-text TextArea fields for IPv4/IPv6 addresses, DNS
nameservers, and DNS search domains with ArrayField. Each field
validates entries on submit; invalid values are rejected with an inline
error.
Validates name (required), IPv4/IPv6 addresses (required when manual,
all valid), gateways (valid if present, mode-aware), DNS servers and
search domains (at least one valid entry when enabled).

Validation logic is extracted into validateConnectionForm and
buildConnection helpers to keep onSubmitAsync readable.

Three related fixes are included:
- ArrayField was showing guidance text ("Select entries to edit…")
  instead of the actual error when a field-level error came from
  onSubmitAsync. Now the error is shown.
- Re-submission after a validation failure had no effect because
  TanStack Form kept canSubmit false once field errors were set. The
  form now clears those errors before each attempt
- IPv4 validation now requires standard four-part decimal notation,
  rejecting values like "1111" that ipaddr.js would otherwise accept.
The `use` prefix should be reserved for React hooks. Rename to customDns
and customDnsSearch.
Copy link
Copy Markdown
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@dgdavid dgdavid merged commit 16dc2f0 into enhance-network-connection-form Mar 31, 2026
4 checks passed
@dgdavid dgdavid deleted the network-tanstack-form-part3 branch March 31, 2026 15:57
dgdavid added a commit that referenced this pull request Apr 1, 2026
This PR continues the network connection form reimplementation, built on
top of #3349. It adds edit
mode, fixes how the form derives the IP method when editing, and
introduces a not-found empty state.

### Edit mode

`ConnectionForm` is split into `NewConnectionForm` and
`EditConnectionForm`, both delegating to a shared
`ConnectionFormContent`. When a route `id` param is present, the form
pre-populates from the existing connection: IP mode, addresses,
gateways, DNS servers, and search domains are all restored. The
connection name field is not shown: it cannot be changed and the name is
already visible in the breadcrumb.

### Not-found empty state

When the connection id from the route does not match any known
connection, `EditConnectionForm` renders a `ConnectionNotFound` empty
state page instead of crashing.

### Postponed for follow-up PRs

- Auto-generated connection name.
- Evaluate if it "Advanced" mode must be shown when config has no method
but system already has addresses.
@imobachgs imobachgs mentioned this pull request Apr 14, 2026
imobachgs added a commit that referenced this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants