fix(mobile): case sheet lift on a partial pan, live placeholder language

- The phone case sheet (#mobileCasePickerModal) is inside .app, so once
  .app follows a pan it takes the same insideLift as the bars. The layout
  gap on top lifted it twice (186px above the keyboard at offsetTop 100).
  Comment, architecture-invariants and a test case updated.
- setHoldUntilEnter() writes the placeholder before the unchanged-mode
  early return, only when the text differs, so a live language switch
  shows up without touching the rest of the field.
- Settings-Reference: Shift+Enter needs a hardware keyboard.
- styles.css: the #cjkInput cap is a backstop now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kamil KaliszandClaude Opus 5.5 committed 2026-11-17 17:08:26 +01:00
1 parent e85bb83353
commit c639b38c1a
7 files changed
+53 -18

No files matched your search

+22 -2
View File
@@ -372,14 +372,34 @@ describe('CJK input: Send on Enter', () => {
// Runs on every session select and SSE reconnect, possibly mid-composition.
const { CjkInput, textarea } = load();
textarea.setAttribute.mockClear();
textarea.placeholder = 'untouched';
const placeholder = textarea.placeholder;
let writes = 0;
Object.defineProperty(textarea, 'placeholder', {
get: () => placeholder,
set: () => {
writes++;
},
});
CjkInput.setHoldUntilEnter(true);
expect(textarea.setAttribute).not.toHaveBeenCalled();
expect(textarea.placeholder).toBe('untouched');
expect(writes).toBe(0);
CjkInput.setHoldUntilEnter(false);
expect(textarea.setAttribute).toHaveBeenCalled();
});
it('follows a live language switch with the mode unchanged', () => {
// App Settings runs applyLocalization(), then _updateCjkInputState(), which
// calls setHoldUntilEnter() with the same mode.
let lang = 'en';
const { CjkInput, textarea } = load({ translate: (s) => (lang === 'zh' ? `zh:${s}` : s) });
expect(textarea.placeholder).toBe('Type, Enter to send (Shift+Enter: new line, Esc: clear)');
textarea.setAttribute.mockClear();
lang = 'zh';
CjkInput.setHoldUntilEnter(true);
expect(textarea.placeholder).toBe('zh:Type, Enter to send (Shift+Enter: new line, Esc: clear)');
expect(textarea.setAttribute).not.toHaveBeenCalled();
});
it('submit() from outside the field (toolbar Enter) sends like Enter', () => {
const { CjkInput, textarea, prompts, sent } = load();
type(textarea, 'go ahead');
@@ -75,6 +75,7 @@ function loadLayout({
'.toolbar': el(),
'.main': el(),
'.keyboard-accessory-bar': el(),
'.mobile-case-picker.active .mobile-case-picker-sheet': el(300),
};
const cjk = { ...el(), id: 'cjkInput' };
const context = vm.createContext({
@@ -126,6 +127,9 @@ describe('KeyboardHandler follows the visual-viewport pan on phones', () => {
expect(nodes['.toolbar'].style.transform).toBe('');
expect(nodes['.keyboard-accessory-bar'].style.transform).toBe('');
expect(cjk.style.transform).toBe('');
// The open case sheet is inside .app too (index.html #mobileCasePickerModal):
// the layout gap on top of the shift floated it 186px above the keyboard.
expect(nodes['.mobile-case-picker.active .mobile-case-picker-sheet'].style.transform).toBe('');
});
it('keeps the old lift when there is no pan', () => {
@@ -133,6 +137,9 @@ describe('KeyboardHandler follows the visual-viewport pan on phones', () => {
kh.updateLayoutForKeyboard();
expect(nodes['.app'].style.transform).toBe('');
expect(nodes['.toolbar'].style.transform).toBe('translateY(-286px)');
// Without a pan insideLift is the layout gap, so the case sheet keeps its lift
// (test/mobile-case-sheet-keyboard-lift.test.ts).
expect(nodes['.mobile-case-picker.active .mobile-case-picker-sheet'].style.transform).toBe('translateY(-286px)');
});
it('follows a pan whatever has focus, so a focus change cannot drop the shift', () => {