fix: Behaviour of homeserver textfield

This commit is contained in:
Christian Pauly 2021-05-01 07:40:12 +02:00
parent 6728993c50
commit 2c8a8a4313
2 changed files with 5 additions and 2 deletions

View File

@ -29,7 +29,8 @@ class HomeserverPickerUI extends StatelessWidget {
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onChanged: (s) => controller.domain = s, onChanged: (s) => controller.domain = s,
readOnly: !AppConfig.allowOtherHomeservers, readOnly: !AppConfig.allowOtherHomeservers,
onSubmit: (_) => controller.checkHomeserverAction, onSubmit: (_) => controller.checkHomeserverAction(),
unfocusOnClear: false,
), ),
elevation: 0, elevation: 0,
), ),

View File

@ -14,6 +14,7 @@ class DefaultAppBarSearchField extends StatefulWidget {
final EdgeInsets padding; final EdgeInsets padding;
final bool readOnly; final bool readOnly;
final Widget prefixIcon; final Widget prefixIcon;
final bool unfocusOnClear;
DefaultAppBarSearchField({ DefaultAppBarSearchField({
Key key, Key key,
@ -27,6 +28,7 @@ class DefaultAppBarSearchField extends StatefulWidget {
this.padding, this.padding,
this.readOnly = false, this.readOnly = false,
this.prefixIcon, this.prefixIcon,
this.unfocusOnClear = true,
}) : super(key: key); }) : super(key: key);
@override @override
@ -105,7 +107,7 @@ class DefaultAppBarSearchFieldState extends State<DefaultAppBarSearchField> {
onPressed: () { onPressed: () {
_searchController.clear(); _searchController.clear();
widget.onChanged?.call(''); widget.onChanged?.call('');
_focusNode.unfocus(); if (widget.unfocusOnClear) _focusNode.unfocus();
}, },
) )
: widget.suffix, : widget.suffix,