Allow +/- to initiate chips on mobile#125
Conversation
There was a problem hiding this comment.
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
handleTextInputto the CQL ProseMirror plugin to detect+/-insertions from input methods that bypasskeydown.
💡 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).
|
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. |
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:
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.