Merge pull request #6166 from sahilyeole/feat/autocomplete

Fix ID text field ui not updating on peer card connection
This commit is contained in:
RustDesk 2023-10-25 11:07:25 +08:00 committed by GitHub
commit 00ab830ad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions

View File

@ -2024,6 +2024,10 @@ connect(
final idController = Get.find<IDTextEditingController>();
idController.text = formatID(id);
}
if (Get.isRegistered<TextEditingController>()){
final fieldTextEditingController = Get.find<TextEditingController>();
fieldTextEditingController.text = formatID(id);
}
} catch (_) {}
}
id = id.replaceAll(' ', '');

View File

@ -81,6 +81,9 @@ class _ConnectionPageState extends State<ConnectionPage>
if (Get.isRegistered<IDTextEditingController>()) {
Get.delete<IDTextEditingController>();
}
if (Get.isRegistered<TextEditingController>()){
Get.delete<TextEditingController>();
}
super.dispose();
}
@ -235,6 +238,7 @@ class _ConnectionPageState extends State<ConnectionPage>
VoidCallback onFieldSubmitted,
) {
fieldTextEditingController.text = _idController.text;
Get.put<TextEditingController>(fieldTextEditingController);
fieldFocusNode.addListener(() async {
_idInputFocused.value = fieldFocusNode.hasFocus;
if (fieldFocusNode.hasFocus && !isPeersLoading){
@ -271,18 +275,6 @@ class _ConnectionPageState extends State<ConnectionPage>
onChanged: (v) {
_idController.id = v;
},
onSubmitted: (s) {
if (s == '') {
return;
}
try {
final id = int.parse(s);
_idController.id = s;
onConnect();
} catch (_) {
return;
}
},
));
},
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<Peer> onSelected, Iterable<Peer> options) {