Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextFormField focus #2462

Open
AndreiJCebotari opened this issue Dec 20, 2024 · 2 comments
Open

TextFormField focus #2462

AndreiJCebotari opened this issue Dec 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@AndreiJCebotari
Copy link

Steps to reproduce

  1. https://github.com/anormaly-io/patrol-integration-tests
  2. branch test-input-focus
  3. patrol develop -t integration_test/text_input_focus_test.dart

Actual results

  1. I write in the text form 'input2' the value 'name 2'
  2. I click on the button to change from read only the to editable the text form 'input1'
  3. I write in the text form 'input1' the value 'input value 1'
  4. The value it's not written in the text form 'input1'

For what I could undersand this way to use the focus doesn't allow to update the text form value.

FocusScope.of(context).requestFocus(_mainFocus);

Another observation it's that if I change the value of 'input1' instead of 'input2' than all works.

Not sure if the way I use focus it's wrong.

Logs

Logs
<!-- Replace this line with your logs. Do not remove the backticks! -->

Patrol version

patrol: ^3.13.1

Patrol Doctor output

Patrol Doctor output
PS E:\workspace\temp-projects\patrol_integration_tests> patrol doctor
Patrol doctor:
Patrol CLI version: 3.4.1
Flutter command: flutter
  Flutter 3.24.3 • channel stable
Android:
• Program adb found in C:\Users\cebot\AppData\Local\Android\Sdk\platform-tools\adb.exe
• Env var $ANDROID_HOME set to C:\Users\cebot\AppData\Local\Android\Sdk

Flutter Doctor output

Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4602], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.2)
[√] IntelliJ IDEA Ultimate Edition (version 2024.2)
[√] VS Code (version 1.95.3)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 1 category.
@FritzMatthaeus
Copy link
Contributor

I am not quite sure, that i got your issue right: But i ran into a similar problem with entering text values into the same TextFormField. After doing some research, it was an underlying Flutter Test issue and it could be solved by just tapping onto the TextFormField every time before entering the value. No need for working with FocusScope in my case.

So i have created this little helper method:

/// Helper method to enter text into a widget as it has to be tapped first
/// if it has no focus
Future<void> enterText(PatrolFinder finder, String text) async {
  await finder.tap();
  await finder.enterText(text);
}

and instead of doing this:

await $(Key.myTextFormField).enterText('myNextTextValue')

i call my helper:

await enterText($(Key.myTextFormField), 'myNextTextValue')

@AndreiJCebotari
Copy link
Author

I see, I just tried but same result. Thanks anyway

@Kendru98 Kendru98 added the bug Something isn't working label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants