Skip to content

Allow +/- to initiate chips on mobile#125

Open
paperboyo wants to merge 2 commits into
mainfrom
mk-claude-mobile-plus-minus
Open

Allow +/- to initiate chips on mobile#125
paperboyo wants to merge 2 commits into
mainfrom
mk-claude-mobile-plus-minus

Conversation

@paperboyo

Copy link
Copy Markdown

Co-authored by Claude Opus 4.6, description written by a human, 48.

What does this change?

Chips are impossible to add using mobile keyboard. This was verified to work. I checked if it negatively affects desktop, but couldn't find any issues. 🤖 was adamant it’s OK, but they often are.

🤖 says:

Fix: chip trigger (+/-) on mobile virtual keyboards

Mobile virtual keyboards (Android, iOS) often don't fire keydown events with correct event.key values for punctuation — they arrive as key: "Unidentified" or go through composition/input events instead. This means the existing handleKeyDown check for +/- never fires on mobile, making chip creation impossible on touch devices.

Fix

Add handleTextInput plugin prop — ProseMirror's input-method-agnostic hook that fires whenever text is inserted regardless of input mechanism. It calls the same maybeAddChipAtPolarityChar function, so all existing guards (no mid-word triggers, - adjacency check) still apply.

Why it's safe for desktop

On desktop, handleKeyDown catches +/- first and returns true → ProseMirror calls preventDefault() → the text is never inserted → handleTextInput never fires. The new code path is unreachable on desktop keyboards.

How has this change been tested?

All 197 tests pass, 0 failures. Tested on Chrome for Android latest beta.

How can we measure success?

If someone would want to use chips on mobile they will feel instant success.

@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

@paperboyo paperboyo added the fix Departmental tracking: fix label May 15, 2026
@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enables chip creation via +/- characters from mobile virtual keyboards, which often don't fire keydown events with reliable event.key values for punctuation. Adds a handleTextInput ProseMirror plugin hook that calls the same chip-creation logic as the existing handleKeyDown path. On desktop, handleKeyDown already preempts the input by returning true, so the new path is only exercised on mobile.

Changes:

  • Add handleTextInput to the CQL ProseMirror plugin to detect +/- insertions from input methods that bypass keydown.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The existing +/- chip-creation tests exercise the handleKeyDown path, which
is reliable on desktop. On mobile, soft keyboards do not fire keydown events
consistently; characters arrive through handleTextInput instead.

Add a "via text input (mobile)" describe block that calls handleTextInput
directly via view.someProp, isolating this path from handleKeyDown:

- '+' received as text input creates a positive chip
- '-' received as text input creates a negative chip
- '+' immediately following a non-whitespace character is treated as literal text
- '-' immediately preceding a non-whitespace character is treated as literal text

The negative cases faithfully simulate the full browser flow: if handleTextInput
returns false, the character is inserted as plain text (the fallback a browser
would perform).
@paperboyo

Copy link
Copy Markdown
Author

Added tests. Claude added, rather. They failed without this code, then succeeded with it, just like all the others, which apparently has a name: TBD… No. TDD, rather.
“If a thing is worth doing, it is worth doing badly”, choir!

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

Labels

fix Departmental tracking: fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants