From ace98d98ad4089deda11135e0ce3001178cd6385 Mon Sep 17 00:00:00 2001 From: shleyZ Date: Wed, 16 Oct 2024 19:25:27 +0800 Subject: [PATCH] fix: TextFormField onChanged event triggered multiple times when Korean input (#9644) * fix: TextFormField onChanged event triggered multiple times when Korean input * logic fix for iOS * add comments * move 'onChanged' logic to handleSoftKeyboardInput --- flutter/lib/mobile/pages/remote_page.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index 19f7cc575..e8a888696 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -242,12 +242,16 @@ class _RemotePageState extends State { } } - // handle mobile virtual keyboard - void handleSoftKeyboardInput(String newValue) { + async void handleSoftKeyboardInput(String newValue) { if (isIOS) { - _handleIOSSoftKeyboardInput(newValue); + // fix: TextFormField onChanged event triggered multiple times when Korean input + // https://github.com/rustdesk/rustdesk/pull/9644 + await Future.delayed(const Duration(milliseconds: 10)); + + if (newValue != _textController.text) return; + return _handleIOSSoftKeyboardInput(_textController.text); } else { - _handleNonIOSSoftKeyboardInput(newValue); + return _handleNonIOSSoftKeyboardInput(newValue); } }