Skip to content

fix: spacebar not working when editing text fields in grid view#8598

Open
yetval wants to merge 3 commits intoAppFlowy-IO:mainfrom
yetval:main
Open

fix: spacebar not working when editing text fields in grid view#8598
yetval wants to merge 3 commits intoAppFlowy-IO:mainfrom
yetval:main

Conversation

@yetval
Copy link
Copy Markdown

@yetval yetval commented Mar 20, 2026

Description

Fixes the spacebar key not working when editing text fields in database grid view on Windows.

Root cause: When a key event is dispatched, Flutter's ancestor Shortcuts widget maps the bare space key to ActivateIntent. When that intent is handled, the engine receives handled: true and suppresses the WM_CHAR message — so the character never reaches the text input system.

Fix: Set onKeyEvent on the text cell's focusNode to return KeyEventResult.skipRemainingHandlers for the space key. This stops ancestor Shortcuts from seeing the event without marking it as "handled", so the platform still generates WM_CHAR and the space is inserted normally.

Closes #8572

Checklist

  • Code follows AppFlowy's conventions
  • At least one related issue is referenced
  • Tests included (UI key event test)
  • Existing tests pass

Summary by Sourcery

Bug Fixes:

  • Prevent the grid text editor from swallowing spacebar presses by skipping remaining key handlers for the space key.

…text input; return skipRemainingHandlers on focusNode to stop propagation without suppressing WM_CHAR
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a key event handler to text grid cells so spacebar presses are skipped for ancestor shortcut handling but still reach the text input system, fixing spacebar input on Windows when editing text fields in the database grid view.

Sequence diagram for handling spacebar key events in grid text cells

sequenceDiagram
  actor User
  participant GridTextCell as GridTextCell
  participant FocusNode as FocusNode
  participant Shortcuts as Shortcuts
  participant PlatformWindow as PlatformWindow
  participant TextInputSystem as TextInputSystem

  User->>GridTextCell: press spacebar
  GridTextCell->>FocusNode: onKeyEvent(KeyDownEvent space)
  FocusNode-->>GridTextCell: KeyEventResult.skipRemainingHandlers
  Note right of FocusNode: Ancestor Shortcuts does not receive the space key event

  GridTextCell->>PlatformWindow: key down event (space)
  PlatformWindow->>PlatformWindow: generate WM_CHAR for space
  PlatformWindow->>TextInputSystem: WM_CHAR ' '
  TextInputSystem-->>GridTextCell: insert space into text field
Loading

File-Level Changes

Change Details Files
Handle spacebar key events at the text cell focus node to bypass ancestor Shortcuts while allowing normal text input.
  • Initialize the text cell's focus node with an onKeyEvent handler.
  • Detect KeyDownEvent for the LogicalKeyboardKey.space key within the handler.
  • Return KeyEventResult.skipRemainingHandlers for spacebar events to prevent Shortcuts from treating them as ActivateIntent.
  • Return KeyEventResult.ignored for all other key events to preserve existing behavior.
frontend/appflowy_flutter/lib/plugins/database/widgets/cell/editable_cell_skeleton/text.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#8572 Allow spacebar input to register when editing database grid text fields on Windows

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The onKeyEvent handler only checks for KeyDownEvent, so holding the spacebar for key repeat may still be intercepted by ancestor shortcuts; consider also handling KeyRepeatEvent for LogicalKeyboardKey.space to keep the behavior consistent.
  • Since the root cause is specific to Windows (WM_CHAR suppression), consider guarding this logic with a platform check so that spacebar shortcuts on other platforms are not unintentionally masked if they rely on ancestor Shortcuts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `onKeyEvent` handler only checks for `KeyDownEvent`, so holding the spacebar for key repeat may still be intercepted by ancestor shortcuts; consider also handling `KeyRepeatEvent` for `LogicalKeyboardKey.space` to keep the behavior consistent.
- Since the root cause is specific to Windows (WM_CHAR suppression), consider guarding this logic with a platform check so that spacebar shortcuts on other platforms are not unintentionally masked if they rely on ancestor `Shortcuts`.

## Individual Comments

### Comment 1
<location path="frontend/appflowy_flutter/lib/plugins/database/widgets/cell/editable_cell_skeleton/text.dart" line_range="70-71" />
<code_context>
     _textEditingController =
         TextEditingController(text: cellBloc.state.content);
+    focusNode.onKeyEvent = (node, event) {
+      if (event is KeyDownEvent &&
+          event.logicalKey == LogicalKeyboardKey.space) {
+        return KeyEventResult.skipRemainingHandlers;
+      }
</code_context>
<issue_to_address>
**question (bug_risk):** Consider whether modifier combinations (e.g., Shift+Space) should also be intercepted, and if not, explicitly filter only unmodified space presses.

Since every LogicalKeyboardKey.space press is skipped, modifier chords like Shift+Space or Ctrl+Space will also be swallowed. If only the plain spacebar should be intercepted, guard against active modifiers (e.g., consult HardwareKeyboard.instance.logicalKeysPressed or the event’s modifier helpers) so shortcut bindings keep working.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] When editing text fields in grid view of DB, space bar key is not working

2 participants