Commit Graph
2 Commits
Author SHA1 Message Date
happy5318 bbebe23f7e fix(mobile): preserve tablet hardware-keyboard Enter behavior 2026-09-24 15:26:06 +08:00
happy5318 2aefdc2522 test(mobile): cover the three soft-keyboard Enter fixes
The 11 existing tests in test_send_key_preference_live_update.py cover the
runtime settings-change path from the previous review round, but reverse-verify
shows they stay green when any of this PR's three production changes is
reverted -- they never exercise the mobile Enter behaviour the PR fixes.

Add tests/test_mobile_enter_newline.py, which drives the real composer handler
and helpers extracted verbatim from boot.js under a mobile UA plus a shim that
reproduces the iOS Safari quirk where (any-pointer:fine) reports true on a
plain iPhone:

- iPhone/Android UA: plain Enter must insert a newline, not send
  (reverting _isTouchOnlyDevice makes both red)
- stored shift+enter preference must hold on the first keypress, and the
  bootstrap must precede handler registration
  (reverting the synchronous window._sendKey init makes both red)
- the composer textarea must declare enterkeyhint and expose it as
  enterKeyHint in the DOM
  (reverting the attribute makes both red)

Also guards the inverse: desktop Enter still sends, and mobile Ctrl+Enter and
Numpad Enter still send, so the fix does not remove the keyboard send path.

Reverse-verified: each production change reverted individually turns exactly
its two tests red; restored tree is byte-identical and all 23 tests pass.
2026-09-20 22:11:03 +08:00