Skip to content

Commit

Permalink
fix: controlled text input on iOS (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanIhnatsiuk authored Oct 16, 2024
1 parent 84a9386 commit dc2d667
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ PODS:
- React-Mapbuffer (0.73.10):
- glog
- React-debug
- react-native-advanced-input-mask (1.0.0-beta.0):
- react-native-advanced-input-mask (1.0.0-beta.1):
- ForkInputMask (~> 7.3.2)
- glog
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -1355,7 +1355,7 @@ SPEC CHECKSUMS:
React-jsinspector: 71e5fb28b810fa199987e600ec8a6e17abee373e
React-logger: 82babb1e3fad0e04750981f24e6c38f644a0bf7c
React-Mapbuffer: 758750eb32350b01dd9c350010aecc46842047bd
react-native-advanced-input-mask: 6b83fdbaab6b94842242ae5740d2d6d4622d645d
react-native-advanced-input-mask: 455e44d4230cbebbba602856b79feadafb39644a
React-nativeconfig: a596be0c98c050b80bc7e262d46a53d4df4ff712
React-NativeModulesApple: 4829cef81c8a322029300b6ff1c5f28768fca85b
React-perflogger: 27b852c78b7be9e0b326e3102c6551529f371f95
Expand Down
1 change: 1 addition & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function App() {
style={styles.maskedTextInput}
onAdvancedMaskTextChange={onChangeText}
primaryMaskFormat="[00]-[00]-[00]"
value={textState.formatted}
autocomplete={true}
allowSuggestions={false}
autocompleteOnFocus={false}
Expand Down
4 changes: 1 addition & 3 deletions ios/MaskedTextInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ class MaskedTextInputDecoratorView: UIView {

@objc var value: NSString = "" {
didSet {
maskInputListener?.autocomplete = false
updateTextWithoutNotification(text: value as String)
maskInputListener?.autocomplete = autocomplete
}
}

Expand All @@ -122,7 +120,7 @@ class MaskedTextInputDecoratorView: UIView {

guard let primaryMask = maskInputListener?.primaryMask else { return }
let caretString = CaretString(
string: text, caretPosition: text.endIndex, caretGravity: CaretString.CaretGravity.forward(autocomplete: autocomplete)
string: text, caretPosition: text.endIndex, caretGravity: CaretString.CaretGravity.forward(autocomplete: false)
)
let result = primaryMask.apply(toText: caretString)

Expand Down

0 comments on commit dc2d667

Please sign in to comment.