Flutter Typeahead focus order using "tab" not working - Stack Overflow

I ran into an issue with TypeAheadField widget where pressing "tab" doesn't go to the ne

I ran into an issue with TypeAheadField widget where pressing "tab" doesn't go to the next text field and instead goes to completely random place. In web, it actually even goes on the browser URL.

I managed to get a repro. If you go from one text field (first or last 2) to the other with "tab" or "Uppercase tab" it works perfectly. But there are 2 bugs:

  • If you go from the second text field and press "tab", you need to press it twice before it actually goes to the TypeAheadField field. Note that if you go the second last and press "uppercase tab" this goes directly to the TypeAheadField field.
  • Once the focus is on the TypeAheadField field, if you press "tab" it doesn't go anywhere useful.

This is especially problematic on web and I guess apps as well.

Any idea how to fix this?

Code:

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  TextEditingController textController = TextEditingController();

  MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Typeahead bug',
      home: Scaffold(
        appBar: AppBar(title: const Text('Login')),
        body: Column(children: [
          TextFormField(),
          TextFormField(),
          TypeAheadField<String>(
            controller: textController,
            hideOnEmpty: true,
            debounceDuration: const Duration(),
            builder: (context, controller, focusNode) {
              return TextFormField(
                  controller: controller,
                  focusNode: focusNode,
                  autofocus: true,
                  decoration: InputDecoration(
                    labelText: 'Typeahead',
                  ));
            },
            suggestionsCallback: (v) => v == "" ? [] : ["a", "b"],
            itemBuilder: (context, v) => ListTile(title: Text(v)),
            onSelected: (String v) {
              textController.text = v;
            },
          ),
          TextFormField(),
          TextFormField(),
        ]),
      ),
    );
  }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744860353a4597665.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信