Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[auth] Potential fix for keyboard popup not working while focusing on search

Neeraj Gupta949a3040785a
diff --git a/auth/lib/ui/home_page.dart b/auth/lib/ui/home_page.dart
index ead979d7da..c3397d79af 100644
--- a/auth/lib/ui/home_page.dart
+++ b/auth/lib/ui/home_page.dart
@@ -51,6 +51,7 @@ class _HomePageState extends State<HomePage> {
final scaffoldKey = GlobalKey<ScaffoldState>();
final TextEditingController _textController = TextEditingController();
+ final FocusNode searchInputFocusNode = FocusNode();
bool _showSearchBox = false;
String _searchText = "";
List<Code> _codes = [];
@@ -80,6 +81,17 @@ class _HomePageState extends State<HomePage> {
setState(() {});
});
_showSearchBox = PreferenceService.instance.shouldAutoFocusOnSearchBar();
+ if (_showSearchBox) {
+ WidgetsBinding.instance.addPostFrameCallback(
+ (_) {
+ // https://github.com/flutter/flutter/issues/20706#issuecomment-646328652
+ FocusScope.of(context).unfocus();
+ Timer(const Duration(milliseconds: 1), () {
+ FocusScope.of(context).requestFocus(searchInputFocusNode);
+ });
+ },
+ );
+ }
}
void _loadCodes() {
@@ -192,6 +204,7 @@ class _HomePageState extends State<HomePage> {
title: !_showSearchBox
? const Text('Ente Auth')
: TextField(
+ focusNode: searchInputFocusNode,
autofocus: _searchText.isEmpty,
controller: _textController,
onChanged: (val) {