TF-4011 Support Tab shortcut key to switch focus between tag & input field

This commit is contained in:
dab246
2025-11-04 11:38:59 +07:00
committed by Dat H. Pham
parent c479d47da8
commit 35fa43ed6b
4 changed files with 787 additions and 725 deletions
File diff suppressed because it is too large Load Diff
@@ -134,6 +134,9 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
void initState() { void initState() {
super.initState(); super.initState();
_currentListEmailAddress = widget.listEmailAddress; _currentListEmailAddress = widget.listEmailAddress;
if (PlatformInfo.isWeb) {
widget.focusNodeKeyboard?.addListener(_onFocusKeyboardListener);
}
} }
@override @override
@@ -144,6 +147,20 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
} }
} }
@override
void dispose() {
if (PlatformInfo.isWeb) {
widget.focusNodeKeyboard?.removeListener(_onFocusKeyboardListener);
}
super.dispose();
}
void _onFocusKeyboardListener() {
if (widget.focusNodeKeyboard?.hasFocus != true && mounted) {
setState(() => _tagIndexFocused = -1);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isMobileResponsive = _responsiveUtils.isMobile(context); bool isMobileResponsive = _responsiveUtils.isMobile(context);
@@ -406,7 +423,9 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
} }
KeyEventResult _recipientInputOnKeyListener(FocusNode node, KeyEvent event) { KeyEventResult _recipientInputOnKeyListener(FocusNode node, KeyEvent event) {
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) { if (widget.focusNode?.hasFocus == true &&
event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.tab) {
widget.nextFocusNode?.requestFocus(); widget.nextFocusNode?.requestFocus();
widget.onFocusNextAddressAction?.call(); widget.onFocusNextAddressAction?.call();
return KeyEventResult.handled; return KeyEventResult.handled;
+2 -2
View File
@@ -2170,10 +2170,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: super_tag_editor name: super_tag_editor
sha256: "83823674fa1048eb0411d169c9072028fa80ba6998ef18b357c29f58b835ea75" sha256: "7f7c1cb38e98e9cfa92fb074d4d5f5f53846d6bffcc96e05cb2191c159dba28d"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.1" version: "1.1.0"
syncfusion_flutter_core: syncfusion_flutter_core:
dependency: transitive dependency: transitive
description: description:
+1 -1
View File
@@ -110,7 +110,7 @@ dependencies:
ref: master ref: master
### Dependencies from pub.dev ### ### Dependencies from pub.dev ###
super_tag_editor: 0.4.1 super_tag_editor: 1.1.0
external_app_launcher: 4.0.3 external_app_launcher: 4.0.3