How do you keep a mobile keyboard from covering the active form field?

Keep form controls in normal document flow and let the browser scroll the focused field into view. Large fixed panels, nested scrollers and bottom action bars often prevent that behavior. Reserve space and test against the visual viewport while the keyboard is open.
Use scroll-margin-block on fields when a sticky header or footer needs clearance. Avoid fixed-height containers that cannot shrink or scroll. A modal form should have a bounded scrolling content region with its title and close control reachable when the visual viewport becomes shorter.
Calling element.scrollIntoView() can help after custom focus changes, but run it after the keyboard and validation layout settle. Do not continuously reposition the page on every visual viewport event. The user should retain control of the scroll position.
Fixed bottom bars may need to move, hide or become part of the form flow while typing. Dynamic viewport units and the Visual Viewport API can support app-like interfaces, but browser behavior differs. Feature-detect APIs and keep a simple scrolling fallback.
Test real iOS and Android devices with different keyboards, orientation changes, zoom and validation errors. Focus the first and last fields inside pages and dialogs. Confirm that error text and the submit action remain visible without trapping users inside multiple nested scrolling regions. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches.