Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: slash menu responds to multiple key events

squidrye5c099297a42d
diff --git a/frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_widget.dart b/frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_widget.dart
index 3a88cfcd4a..8af25c7325 100644
--- a/frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_widget.dart
+++ b/frontend/appflowy_flutter/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_widget.dart
@@ -324,7 +324,7 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
_deleteLastCharacters();
return KeyEventResult.handled;
} else if (event.character != null &&
- !arrowKeys.contains(event.logicalKey)) {
+ !arrowKeys.contains(event.logicalKey) && event.logicalKey != LogicalKeyboardKey.tab) {
keyword += event.character!;
_insertText(event.character!);
return KeyEventResult.handled;
@@ -339,7 +339,18 @@ class _SelectionMenuWidgetState extends State<SelectionMenuWidget> {
newSelectedIndex -= 1;
} else if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
newSelectedIndex += 1;
+ }else if (event.logicalKey == LogicalKeyboardKey.tab) {
+ newSelectedIndex += widget.maxItemInRow;
+ var currRow = (newSelectedIndex) % widget.maxItemInRow;
+ if (newSelectedIndex >= _showingItems.length) {
+ if (currRow + 1 >= widget.maxItemInRow) {
+ newSelectedIndex = 0;
+ } else {
+ newSelectedIndex = (currRow + 1);
+ }
+ }
}
+
if (newSelectedIndex != _selectedIndex) {
setState(() {
_selectedIndex = newSelectedIndex.clamp(0, _showingItems.length - 1);