-
Notifications
You must be signed in to change notification settings - Fork 172
Description
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
- Open the iOS app
- Navigate to create a derived key
- Enter an invalid derivation path (e.g., one that causes a collision or is malformed)
- Observe that the text field content turns red and shows an error message
- 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 }
)
)