#23538·clients

Inline menu is misplaced for fields in an iframe inside a shadow root

Author: BryceBarbaraRezCreated Sep 29, 2026Updated Sep 30, 2026

Steps To Reproduce

  1. Save the two files below in one folder and serve it locally (for example python3 -m http.server 8000), then open http://localhost:8000/repro.html.
  2. The page shows the same login form twice, in an iframe. A is an iframe in the page's normal DOM. B is the same iframe, but appended inside an open shadow root of a custom element (a common pattern for embeddable widgets).
  3. Focus the username field in A: the inline menu appears under the field.
  4. Focus the username field in B: the inline menu appears in the wrong place.

login.html:

xml
<!doctype html>
<meta charset="utf-8">
<form style="font: 16px system-ui">
  <label>Username <input name="username" autocomplete="username"></label><br><br>
  <label>Password <input name="password" type="password" autocomplete="current-password"></label>
</form>

repro.html:

xml
<!doctype html>
<meta charset="utf-8">
<title>Inline menu: iframe inside a shadow root</title>
<style>body { font: 16px system-ui; margin: 40px 40px 40px 420px; } iframe { width: 360px; height: 180px; border: 1px solid #999; }</style>
<h2>A: iframe in the light DOM (works)</h2>
<iframe src="login.html?a"></iframe>
<h2>B: the same iframe inside an open shadow root (menu misplaced)</h2>
<login-widget></login-widget>
<script>
  customElements.define('login-widget', class extends HTMLElement {
    connectedCallback() {
      const root = this.attachShadow({ mode: 'open' });
      root.innerHTML = '<style>iframe { width: 360px; height: 180px; border: 1px solid #999; }</style>';
      const f = document.createElement('iframe');
      f.src = 'login.html?b';
      root.appendChild(f);
    }
  });
</script>

Expected Result

The inline menu is positioned under the focused field in both cases, as it is for A.

Actual Result

For B, the inline menu is drawn as if the iframe were at the top-left corner of the page: at the field's position within the iframe, measured from the page's origin. With the iframe away from the page's left edge (as in the repro), the menu appears far to the left of the field.

We hit this with a booking widget that renders a cross-origin iframe inside a custom element's shadow root: on name and email fields, the menu appeared on the left side of the screen while the fields were on the right. Moving the <iframe> element into the light DOM (slotted into the shadow root) fixes it.

Screenshots or Videos

Screenshots from the booking widget, one with the iframe in the light DOM (menu placed correctly): Image

and one with it inside a shadow root (menu misplaced). Image

Additional Context

From reading apps/browser/src/autofill/services/autofill-overlay-content.service.ts on main, this looks like the cause:

  • getSubFrameOffsets finds the sub-frame's iframe with globalThis.document.getElementsByTagName("iframe"), and the fallback calculateSubFramePositioning uses globalThis.document.querySelectorAll("iframe"). Neither query enters shadow roots, so an iframe inside a shadow root is never found.
  • In calculateSubFramePositioning, when no iframe matches event.source, the loop ends without returning, and the top frame sends updateSubFrameData with the initial { top: 0, left: 0 }. overlay.background.ts stores that as the frame's offset, so the menu is positioned as if the frame were at the page's corner, rather than staying hidden (which is what a null offset does).

Possible fixes: search open shadow roots when looking for the iframe (for example, walk element.shadowRoot recursively, or use event.source together with a deep query); and when no iframe matches, leave the offset null rather than storing 0,0, so the menu hides instead of appearing in the wrong place.

Operating System

macOS

Operating System Version

macOS 27.0 (26A428)

Web Browser

Chrome

Browser Version

154.0.8037.58

Environment Versions

Version: 2026.8.0
SDK: 'main (eb825d5)'
Server version: 2026.9.1

Issue Tracking Info

  • I understand that work is tracked outside of GitHub. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.