diff --git a/CHANGELOG.md b/CHANGELOG.md index d7d3e34..0ce2a78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.4 + +* fix focus action not working sometimes + ## 1.2.3 * fix placeholder re-appeared upon widget rebuilt diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 0378d59..ff15462 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,6 +1,6 @@ PODS: - Flutter (1.0.0) - - flutter_native_text_input (1.2.3): + - flutter_native_text_input (1.2.4): - Flutter DEPENDENCIES: @@ -15,8 +15,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a - flutter_native_text_input: 64d4cedbc245cc766a50bbbee93e29a3ea0595c3 + flutter_native_text_input: 8d9586a82ca14b2bb437930b4041db9e9ff1a423 PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d -COCOAPODS: 1.11.2 +COCOAPODS: 1.10.1 diff --git a/ios/flutter_native_text_input.podspec b/ios/flutter_native_text_input.podspec index 0f2fe54..e3fe33d 100644 --- a/ios/flutter_native_text_input.podspec +++ b/ios/flutter_native_text_input.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_native_text_input' - s.version = '1.2.3' + s.version = '1.2.4' s.summary = 'Native text input for Flutter' s.description = <<-DESC Native text input for Flutter diff --git a/lib/flutter_native_text_input.dart b/lib/flutter_native_text_input.dart index 150c007..d033e3f 100644 --- a/lib/flutter_native_text_input.dart +++ b/lib/flutter_native_text_input.dart @@ -229,11 +229,7 @@ class _NativeTextInputState extends State { super.initState(); _effectiveFocusNode.addListener(() { - if (_effectiveFocusNode.hasFocus) { - _channel.invokeMethod("focus"); - } else { - _channel.invokeMethod("unfocus"); - } + _channel.invokeMethod(_effectiveFocusNode.hasFocus ? "focus" : "unfocus"); }); if (widget.controller != null) { @@ -411,16 +407,13 @@ class _NativeTextInputState extends State { // input control methods void _inputStarted() { _scrollIntoView(); - Future.delayed(const Duration(milliseconds: 1000)).then((value) { + if (!_effectiveFocusNode.hasFocus) FocusScope.of(context).requestFocus(_effectiveFocusNode); - }); } void _inputFinished(String? text) { _channel.invokeMethod("unfocus"); - if (_effectiveFocusNode.hasFocus) { - FocusScope.of(context).unfocus(); - } + if (_effectiveFocusNode.hasFocus) FocusScope.of(context).unfocus(); if (widget.onSubmitted != null) { Future.delayed(Duration(milliseconds: 100), () { widget.onSubmitted!(text); diff --git a/pubspec.yaml b/pubspec.yaml index dc55edd..de6cd24 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_native_text_input description: Native text input for Flutter. Currently iOS-only with the use of UITextView. -version: 1.2.3 +version: 1.2.4 homepage: https://github.com/henryleunghk/flutter-native-text-input environment: