Skip to content

fix(android-webview): prevent content loss on Enter after heading formatting #1721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

egoing
Copy link

@egoing egoing commented May 28, 2025

  • Add isMenuVisible parameter to SuggestionMenu keyboard handlers
  • Prevent keyboard event processing when menu is not visible
  • Strengthen validation for menu state and DOM existence during Enter key handling
  • Apply consistent logic to both GridSuggestionMenu and regular SuggestionMenu
  • Add selected index validity checks

This change prevents the unintended activation of suggestion menu keyboard handlers when pressing Enter after applying title or other formatting in Android WebView environments, which was causing content to disappear. By ensuring keyboard events are only processed when the menu is actually displayed and exists in the DOM, this improves the stability of user input handling.

Testing approach:

  1. Open BlockNote editor in Android WebView
  2. Input text and apply title formatting (H1, H2, etc.)
  3. Press Enter while formatting is applied
  4. Verify that existing content doesn't disappear and a new line is created
  5. Confirm that Enter key selection works properly when suggestion menu is displayed
  6. Perform regression testing across various browser environments

…le formatting in Android WebView

- Add isMenuVisible parameter to SuggestionMenu keyboard handlers
- Prevent keyboard event processing when menu is not visible
- Strengthen validation for menu state and DOM existence during Enter key handling
- Apply consistent logic to both GridSuggestionMenu and regular SuggestionMenu
- Add selected index validity checks

This change prevents the unintended activation of suggestion menu keyboard handlers
when pressing Enter after applying title or other formatting in Android WebView environments,
which was causing content to disappear. By ensuring keyboard events are only processed
when the menu is actually displayed and exists in the DOM, this improves the stability
of user input handling.

Testing approach:
1. Open BlockNote editor in Android WebView
2. Input text and apply title formatting (H1, H2, etc.)
3. Press Enter while formatting is applied
4. Verify that existing content doesn't disappear and a new line is created
5. Confirm that Enter key selection works properly when suggestion menu is displayed
6. Perform regression testing across various browser environments
Copy link

vercel bot commented May 28, 2025

@egoing is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@egoing
Copy link
Author

egoing commented May 28, 2025

In the WebView, after selecting a format and pressing Enter, the content disappears like this.

3.mov

@egoing
Copy link
Author

egoing commented Jun 7, 2025

Yousef

Hi @YousefED 😊

This PR addresses an issue where content disappears in Android WebView when a format is applied and the user presses Enter after typing.
I’ve attached a screen recording demonstrating the issue: after applying a format and typing some text, pressing Enter causes the content to vanish.

This is currently affecting our app in production, and we've had to apply a monkey patch as a temporary workaround.
It would be greatly appreciated if you could take a look at this PR when you get a chance.
I'm happy to make any changes if needed.

Thank you so much 🙏

IMG_1915.2.mov

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.

1 participant