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

Pressing enter in non-expanded SearchAnchor.bar loses focus #141395

Closed
parlough opened this issue Jan 11, 2024 · 5 comments
Closed

Pressing enter in non-expanded SearchAnchor.bar loses focus #141395

parlough opened this issue Jan 11, 2024 · 5 comments
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@parlough
Copy link
Member

Steps to reproduce

  1. Add a SearchAnchor.bar to your app
  2. Run the app. (I tried macOS, CanvasKit, and skwasm)
  3. Tab into the search bar
  4. Click enter without typing anything (or after typing close search view and then click enter)
  5. Notice focus is lost. At least on web, it returns to beginning of app.

Expected results

If the user hasn't changed the submission behavior, pressing "Enter" either does nothing or opens up the expanded search view.

Actual results

Focus is lost/reset when pressing Enter.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: SizedBox(
            width: 320,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                SearchAnchor.bar(
                  barHintText: 'Search',
                  suggestionsBuilder: (context, controller) {
                    return [];
                  },
                ),
                TextField(),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Video demonstration

Expand for video

It's a bit hard to show in a video, but in the following video I tab into the search bar, and try clicking "Enter", but then focus is lost. Then I bring focus back to the search bar, type something to open the expanded view, escape, then try clicking "Enter" for the same thing to occur:

SearchBarFocusBeingLost.mov

Flutter version info

Version
Flutter 3.19.0-3.0.pre.43 • channel main • https://github.com/flutter/flutter
Framework • revision f961fdf2ba (4 hours ago) • 2024-01-10 17:37:07 -0500
Engine • revision a045134c91
Tools • Dart 3.4.0 (build 3.4.0-14.0.dev) • DevTools 2.31.0
@huycozy
Copy link
Member

huycozy commented Jan 12, 2024

Hi @parlough
I also see the same behavior with a simple TextField so I think it's WAI. In case you want to keep the focus when pressing Enter key, you may try using textInputAction: TextInputAction.none for it. Do you find it appropriate to your case?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 12, 2024
@parlough
Copy link
Member Author

Hey @huycozy! Thanks for checking in :)

If this is the case for TextField as well, I feel it's an accessibility issue for both widgets. The default behavior resetting focus to the beginning of the app could completely mess up a keyboard user's workflow.

Also as far as I can tell, SearchAnchor.bar doesn't have a textInputAction or similar.

What do you think?

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 12, 2024
@huycozy
Copy link
Member

huycozy commented Jan 15, 2024

SearchAnchor.bar doesn't have a textInputAction or similar.

It does :). There is a PR completed recently for this at #138553 (it's not landed to stable yet)

Since this issue is on TextField in general, could you please update the issue to correspond with that? This is more like a proposal so opening a new proposal could also be an option.

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 15, 2024
Copy link

github-actions bot commented Feb 5, 2024

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

@github-actions github-actions bot closed this as completed Feb 5, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

2 participants