Skip to content

Focus still on Input after clicking Button #4759

Closed

Description

@arxenix

I have a view like this: https://gyazo.com/9b8d7726230884017002c6ed9818ac25

When I click the "Go" RaisedButton, the focus remains on the text input and the keyboard remains open (on both iOS and Android)

I believe this may be a bug? I would expect the keyboard to close automatically after clicking the button. I had to close it manually by calling Focus.clear in the onPressed of the button.

return new Block(
                padding: new EdgeInsets.only(top: kTextTabBarHeight + kToolBarHeight + statusBarHeight),
                scrollableKey: page.key,
                children: <Widget>[
                  new Form(
                    onSubmitted: _handleSubmitted,
                    child: new Block(
                      padding: const EdgeInsets.all(8.0),
                      children: <Widget>[
                        new Center(
                          child: new Text(
                            "Enter the LaundryAlert login code for your university",
                            textAlign: TextAlign.center
                          )
                        ),
                        new Input(
                          hintText: 'The LaundryAlert password for your school',
                          labelText: 'Password',
                          formField: new FormField<String>(
                            setter: (String val) { _code = val; },
                            validator: _validatePassword
                          )
                        ),
                        new RaisedButton(
                          child: new Text('Go!'),
                          onPressed: _handleSubmitted
                        )
                      ]
                    )
                  )
                ]
              );

Flutter Doctor

[✓] Flutter (on Mac OS, channel alpha)
• Flutter at /Users/balajisundara/Documents/flutter/flutter
• Framework revision 9c0c022 (24 hours ago), engine revision bb98655

[✓] Android toolchain - develop for Android devices (Android SDK 24.0.0)
• Android SDK at /Users/balajisundara/Library/Android/sdk
• Platform android-24, build-tools 24.0.0
• Java(TM) SE Runtime Environment (build 1.8.0_91-b14)

[✓] iOS toolchain - develop for iOS devices (Xcode 8.0)
• XCode at /Applications/Xcode-beta.app/Contents/Developer
• Xcode 8.0, Build version 8S128d

[✓] Atom - a lightweight development environment for Flutter
• flutter plugin version 0.2.3
• dartlang plugin version 0.6.27

Activity

  1. abarth commented on Jun 26, 2016

    @abarth
    Contributor

    What does the _handleSubmitted function do? It's not in your code snippet.

  2. self-assigned this
    on Jun 26, 2016
  3. added
    a: text inputEntering text in a text field or keyboard related problems
    on Jun 26, 2016
  4. arxenix commented on Jun 26, 2016

    @arxenix
    Author

    @abarth Sorry about that. Here's the function

    The entire project is up at https://github.com/bobacadodl/LaundryAlert

      void _showInSnackBar(String value) {
       _scaffoldKey.currentState.showSnackBar(new SnackBar(
         content: new Text(value)
       ));
      }
    
      void _handleSubmitted() {
        print('submitted form');
        http.get("https://www.laundryalert.com/cgi-bin/${_code}/LMPage").then((response) {
          if(response.statusCode!=404) {
            if(!kRoutes.containsKey('dormlist/$_code')) {
              kRoutes['dormlist/$_code'] = (BuildContext context) => new DormList(code: _code, name: _code);
            }
            Navigator.pushNamed(context, 'dormlist/${_code}');
          }
          else {
            Focus.clear(context);
            _showInSnackBar("Error - Invalid school code! Please report this to the app authors if you believe it is an error.");
          }
        });
      }
    
  5. modified the milestone: on Jul 19, 2016
  6. removed this from the milestone on Aug 22, 2016
  7. modified the milestone: on Sep 12, 2016
  8. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Sep 12, 2016
  9. mpcomplete commented on Dec 8, 2016

    @mpcomplete
    Contributor

    Same as #6603 .

  10. added a commit that references this issue on Apr 3, 2018
  11. added a commit that references this issue on May 14, 2018
  12. github-actions commented on Aug 15, 2021

    @github-actions

    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.

  13. locked as resolved and limited conversation to collaborators on Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions