Skip to content

Commit

Permalink
fix: ImpaktfullUiInputField now correctly handles the focus (removed …
Browse files Browse the repository at this point in the history
…duplicate events)
  • Loading branch information
vanlooverenkoen committed Jan 7, 2025
1 parent 3bfc181 commit 006cbb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"android":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"macos":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"linux":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"windows":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"web":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","dependencies":[]}]},"dependencyGraph":[{"name":"rive_common","dependencies":[]}],"date_created":"2025-01-07 14:54:11.015245","version":"3.24.4","swift_package_manager_enabled":false}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"android":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"macos":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"linux":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"windows":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"web":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","dependencies":[]}]},"dependencyGraph":[{"name":"rive_common","dependencies":[]}],"date_created":"2025-01-07 15:15:40.570434","version":"3.24.4","swift_package_manager_enabled":false}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.28.1

## Fix

- ImpaktfullUiInputField now correctly handles the focus (removed duplicate events)

# 0.28.0

## Feat
Expand Down
12 changes: 5 additions & 7 deletions lib/src/components/input_field/input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class _ImpaktfullUiInputFieldState extends State<ImpaktfullUiInputField> {
_controller =
widget.controller ?? TextEditingController(text: widget.value);
_focusNode = widget.focusNode ?? FocusNode();
_focusNode.addListener(_onFocusChanged);
if (widget.autofocus) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_focusNode.requestFocus();
Expand All @@ -120,7 +119,6 @@ class _ImpaktfullUiInputFieldState extends State<ImpaktfullUiInputField> {
if (widget.controller == null) {
_controller.dispose();
}
_focusNode.removeListener(_onFocusChanged);
if (widget.focusNode == null) {
_focusNode.dispose();
}
Expand Down Expand Up @@ -259,7 +257,7 @@ class _ImpaktfullUiInputFieldState extends State<ImpaktfullUiInputField> {
placeholder: widget.placeholder,
autofocus: widget.autofocus,
multiline: widget.multiline,
onFocusChanged: widget.onFocusChanged,
onFocusChanged: _onFocusChanged,
readOnly: widget.readOnly,
textAlign: widget.textAlign,
),
Expand Down Expand Up @@ -310,7 +308,7 @@ class _ImpaktfullUiInputFieldState extends State<ImpaktfullUiInputField> {

void _onFocus() => _focusNode.requestFocus();

void _onFocusChanged() {
void _onFocusChanged(bool hasFocus) {
final hasFocus = _focusNode.hasFocus;
final controller = widget.controller;
if (hasFocus &&
Expand All @@ -329,9 +327,9 @@ class _ImpaktfullUiInputFieldState extends State<ImpaktfullUiInputField> {

void _onSubmitFromVirtualKeyboard() {
Navigator.pop(context);
final onChanged = widget.onChanged;
if (onChanged == null) return;
onChanged(_controller.text);
final onSubmit = widget.onSubmit;
if (onSubmit == null) return;
onSubmit(_controller.text);
}

void _onObscureTextHideShowIconTapped() {
Expand Down

0 comments on commit 006cbb6

Please sign in to comment.