mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
fix(native): a field on a page as tall as the screen comes up above the keyboard on iOS
The login on an iPhone scrolls in no pane of its own, and the keyboard plugin holds the body's height, so the page had nothing to scroll by and the password field stayed under the keyboard, most of all with an error shown above it. Such a page now gets room as tall as the keyboard at its end and scrolls the field above it; the room goes with the keyboard.
This commit is contained in:
@@ -54,6 +54,29 @@ describe('keepFieldInView', () => {
|
||||
expect(scroller.style.paddingBottom).toBe('');
|
||||
});
|
||||
|
||||
it('FE-NATIVE-KBFIELD-004: a page as tall as the screen gets room at its end and scrolls the field above the keyboard', () => {
|
||||
// The login on an iPhone: no pane scrolls, and the keyboard plugin holds the body's height.
|
||||
Object.defineProperty(window, 'innerHeight', { configurable: true, value: 1000 });
|
||||
const scrollBy = vi.spyOn(window, 'scrollBy').mockImplementation(() => {});
|
||||
const form = document.createElement('form');
|
||||
document.body.appendChild(form);
|
||||
field(form, 'input', 760, 800);
|
||||
|
||||
revealFocusedField(KEYBOARD);
|
||||
const room = document.body.lastElementChild as HTMLElement;
|
||||
expect(room.getAttribute('aria-hidden')).toBe('true');
|
||||
expect(room.style.height).toBe('300px');
|
||||
expect(scrollBy).toHaveBeenCalledWith({ top: 800 - (700 - 24), behavior: 'smooth' });
|
||||
|
||||
// The next field asks again without stacking a second room.
|
||||
revealFocusedField(KEYBOARD);
|
||||
expect(document.querySelectorAll('[aria-hidden="true"]')).toHaveLength(1);
|
||||
|
||||
releaseRoom();
|
||||
expect(room.isConnected).toBe(false);
|
||||
scrollBy.mockRestore();
|
||||
});
|
||||
|
||||
it('FE-NATIVE-KBFIELD-002: listens for the keyboard coming up and going', () => {
|
||||
const addListener = vi.fn(async () => ({ remove: vi.fn() }));
|
||||
keepFieldInView({ addListener } as never);
|
||||
|
||||
Reference in New Issue
Block a user