Skip to content

iOS: Derivation Path Name field validation state doesn't update after text change #2529

@stepanLav

Description

@stepanLav

Description

The "Derivation Path Name" text field in the iOS app shows a red validation state when validation fails, but the red color persists even after the user corrects the input and validation passes successfully.

Steps to Reproduce

  1. Open the iOS app
  2. Navigate to create a derived key
  3. Enter an invalid derivation path (e.g., one that causes a collision or is malformed)
  4. Observe that the text field content turns red and shows an error message
  5. Modify the text to a valid derivation path

Expected: The text field should return to normal color when validation passes

Actual: The text field content remains red even though validation now passes (no error message is shown)

Example:

ScreenRecording_11-19-2025.12-51-52_1.mov

Root Cause

The issue is in ios/PolkadotVault/Screens/DerivedKey/DerivationPathNameView.swift at line 50:

TextField("", text: $viewModel.inputText)
    .primaryTextFieldStyle(
        Localizable.CreateDerivedKey.Modal.Path.Placeholder.path.string,
        text: $viewModel.inputText,
        isValid: .constant(viewModel.derivationPathError == nil)  // ❌ Problem here
    )

The problem is that .constant() creates a constant binding that evaluates viewModel.derivationPathError == nil only once when the view is created. When derivationPathError changes later (either set to an error or cleared to nil), the binding doesn't update because it's a constant.

Proposed Solution

Replace the .constant() binding with a proper computed binding that reacts to changes in viewModel.derivationPathError:

TextField("", text: $viewModel.inputText)
    .primaryTextFieldStyle(
        Localizable.CreateDerivedKey.Modal.Path.Placeholder.path.string,
        text: $viewModel.inputText,
        isValid: Binding(
            get: { viewModel.derivationPathError == nil },
            set: { _ in }
        )
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions