iOS 26 Safari & WebView: VisualViewport.offsetTop not reset after keyboard dismissal, causing fixed elements misplacement

1. System/device combinations where the issue does not occur:

Physical device: iOS 26.0 (23A5318c) + iPhone 16 Pro Max

2. System/device combinations where the issue does occur:

System versions:

Physical device: iOS 26.0 (23A5330a), iOS 26.0 (23A340) Simulator: iOS 26.0 (23A339)

Device models:

Physical device: iPhone 12

Reproducible in Safari, WKWebView, and UIWebView:

Yes

Actual behavior

In WebView (and identically in Safari):

  • Before the keyboard is shown, header/footer elements with position: fixed are correctly aligned with the screen viewport. Scrolling up/down works as expected.

  • After the keyboard appears, the visualViewport position changes.

  • Bug: When the keyboard is dismissed, visualViewport.offsetTop does not reset to 0. As a result, fixed header/footer elements remain misaligned:

    • When scrolling down, the position looks correct.
    • When scrolling up, the header/footer are visibly offset.

Steps to reproduce

  1. Focus an input field → the keyboard appears
  2. Dismiss the keyboard
  3. Observe that visualViewport.offsetTop remains >0 (does not reset to zero)
  4. position: fixed header/footer elements are misplaced relative to the screen

Expected behavior

  1. After the keyboard is dismissed, visualViewport.height should return to match the layout viewport, and visualViewport.offsetTop should reset to 0.
  2. When scrolling upward, fixed elements should remain correctly positioned within the layout viewport.

Minimal reproducible demo

A simple HTML file containing:

  • A header and footer with position: fixed
  • An input element to trigger the keyboard
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
        <title>H5 吸顶吸底页面 Demo</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }

            body {
                font-family: Arial, sans-serif;
                height: 2000px; /* 设置内容高度 */
                background-color: #f0f8ff; /* body 背景浅蓝色 */
                padding-top: 120px; /* 预留 header 高度 */
                padding-bottom: 60px; /* 预留 footer 高度 */
                overflow-x: hidden;
            }

            /* 吸顶 Header */
            header {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 120px;
                background-color: #ff6b6b; /* 红色 */
                display: flex;
                align-items: center;
                justify-content: center;
                color: white;
                font-size: 24px;
                font-weight: bold;
                z-index: 1000;
            }

            /* 吸底 Footer */
            footer {
                position: fixed;
                bottom: 0;
                left: 0;
                width: 100%;
                height: 60px;
                background-color: #4ecdc4; /* 青绿色 */
                display: flex;
                align-items: center;
                justify-content: center;
                color: white;
                font-size: 18px;
                font-weight: bold;
                z-index: 1000;
            }

            /* 输入框样式 */
            .input-container {
                margin: 100px auto;
                width: 80%;
                max-width: 600px;
                text-align: center;
            }

            input[type='text'] {
                padding: 12px;
                font-size: 16px;
                border: 2px solid #ddd;
                border-radius: 8px;
                width: 100%;
                box-sizing: border-box;
            }

            input[type='text']:focus {
                outline: none;
                border-color: #4ecdc4;
            }
        </style>
    </head>
    <body>
        <!-- 吸顶 Header -->
        <header>吸顶 Header (120px)</header>

        <!-- 主体内容 -->
        <div class="input-container">
            <input type="text" placeholder="请输入内容..." />
        </div>

        <!-- 吸底 Footer -->
        <footer>吸底 Footer (60px)</footer>
    </body>
</html>
Answered by DTS Engineer in 857887022

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

Behavior bugs don't only occur when opening/closing the keyboard.

It's the overall behavior of elements in sticky/absolute/fixed positions that are broken because of this new weird viewport.

For example, if you go to Apple's website (https://www.apple.com/) and scroll down, the header will be sticky, but if you look closely, part of the header will extend a few pixels above the viewport.

This is the bug report on Webkit's tracker: https://bugs.webkit.org/show_bug.cgi?id=297779

Might be worth chiming in there to get their attention.

This even happens on the Apple website, for example when viewing feature details on the iPad Air website

What is going on with that? anyone has any update?

iOS 26 Safari & WebView: VisualViewport.offsetTop not reset after keyboard dismissal, causing fixed elements misplacement
 
 
Q