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

Can't focus Textfield after switching tabs with BottomNavigationBar #24436

Closed
Syphonjr opened this issue Nov 16, 2018 · 3 comments
Closed

Can't focus Textfield after switching tabs with BottomNavigationBar #24436

Syphonjr opened this issue Nov 16, 2018 · 3 comments

Comments

@Syphonjr
Copy link

Syphonjr commented Nov 16, 2018

Hi, I have an application with 3 tabs where I use AutomaticKeepAliveClientMixin to keep my navigation state in my tabs. In my tabs I have textfields but after switching tabs, I can only edit the textfield in the second tab,I can't focus and edit anymore on the remaining ones. I can still however copy and paste and press on buttons.

I created a new application and the problem still persist.

Code

My bottom navigation in my main view

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: PageView(
        children: [new HomeTab(), new PresentationsTab(), new ThirdTab()],
        controller: _pageController,
        onPageChanged: pageChanged,
      ),
      bottomNavigationBar: new BottomNavigationBar(
        currentIndex: _page,
        onTap: tapBottomNav,
        items: [
          new BottomNavigationBarItem(
            icon: new Icon(Icons.home),
            title: new Text('Home'),
          ),
          new BottomNavigationBarItem(
            icon: new Icon(Icons.pregnant_woman),
            title: new Text('Presentation'),
          ),
          new BottomNavigationBarItem(
            icon: new Icon(Icons.pregnant_woman),
            title: new Text('Presentation'),
          )
        ],
      ),
    );
  

My HomeTab() (other widgets look the same)

import 'package:flutter/material.dart';
import 'choosepage.dart';

class HomeTab extends StatefulWidget {
  @override
  HomeTabState createState() {
    return new HomeTabState();
  }
}

class HomeTabState extends State<HomeTab>
    with AutomaticKeepAliveClientMixin<HomeTab> {
  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    return new Navigator(
      initialRoute: 'home/chooseroom',
      onGenerateRoute: (RouteSettings settings) {
        WidgetBuilder builder;
        switch (settings.name) {
          case 'home/chooseroom':
            // Assume CollectPersonalInfoPage collects personal info and then
            // navigates to 'signup/choose_credentials'.
            builder = (BuildContext _) => new ChoosePage();
            break;
          default:
            throw new Exception('Invalid route: ${settings.name}');
        }
        return new MaterialPageRoute(builder: builder, settings: settings);
      },
    );
  }
}

And choose page just builds a textfield

Steps to Reproduce

  1. Start the application
  2. Switch tabs
  3. Can't focus on textinput

Flutter Doctor

[√] Flutter (Channel beta, v0.9.4, on Microsoft Windows [Version 10.0.17134.407], locale en-US)
    • Flutter version 0.9.4 at C:\Users\micha\Desktop\AF\flutter_windows_v0.8.2-beta\flutter
    • Framework revision f37c235c32 (7 weeks ago), 2018-09-25 17:45:40 -0400
    • Engine revision 74625aed32
    • Dart version 2.1.0-dev.5.0.flutter-a2eb050044

[√] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    • Android SDK at C:\Users\micha\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.2
    • ANDROID_HOME = C:\Users\micha\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    • All Android licenses accepted.

[√] Android Studio (version 3.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 28.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[√] VS Code, 64-bit edition (version 1.28.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.20.0

[√] Connected devices (1 available)
    • Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 8.0.0 (API 26) (emulator)

• No issues found!
@Syphonjr
Copy link
Author

Oh I found the same issue #17098

@zoechi
Copy link
Contributor

zoechi commented Nov 19, 2018

@Syphonjr thanks for tracking down #17098 ... merging.

@github-actions
Copy link

github-actions bot commented Sep 1, 2021

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 Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants