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() {
super.initState();
_currentListEmailAddress = widget.listEmailAddress;
if (PlatformInfo.isWeb) {
widget.focusNodeKeyboard?.addListener(_onFocusKeyboardListener);
}
}
@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
Widget build(BuildContext context) {
bool isMobileResponsive = _responsiveUtils.isMobile(context);
@@ -406,7 +423,9 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
}
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.onFocusNextAddressAction?.call();
return KeyEventResult.handled;