Skip to content

iOS Safari / mobile web: pasting large text in composer pushes toolbar under virtual keyboard and blocks scroll (calc(50dvh - 3rem)) #3950

Open

Description

@VKirill

Summary

When drafting or pasting messages in the thread composer on iOS (both in the official @bb/mobile iOS app and in mobile Safari):

  1. Composer expansion & toolbar overflow: The composer expands beyond the visible screen area (calc(50dvh - 3rem) in existing threads, and calc(70dvh - 3rem) in new chats / root-compose), pushing the bottom action bar (model selector, voice microphone button, paperclip, send button) beneath the on-screen keyboard.
  2. Caret trapping in text: Single-finger swipe inside the focused ProseMirror text area is captured by WebKit as cursor navigation rather than scrolling data-promptbox-editor-scroll. Users cannot scroll down to place the cursor (caret |) at the end of their text.
  3. Voice dictation blocked: Because the editor doesn't scroll to the end and the bottom toolbar is pushed under the keyboard, users cannot place the cursor at the end of their draft to activate the microphone button for appended voice input.
  4. Timeline occlusion & no way to dismiss keyboard: The expanded composer (~400px–550px) + software keyboard (~340px) occupy the entire screen (~850px), reducing the visible chat history to an unusable ~0–20px sliver. Because hideKeyboardAccessoryView hides the native iOS "Done" bar and BottomAnchoredScrollBody does not blur the input on timeline touch, users cannot dismiss the keyboard or scroll up to read previous assistant messages while composing.

Versions and environment

  • Client: Official iOS App (@bb/mobile, React Native WKWebView shell) and mobile Safari
  • bb: 0.43.1
  • Source reference on main: c1a64f4b49b0659e92a7aa4434e79d062b3e814f
  • Investigation thread: thr_rj96urndqv

Steps to reproduce

Scenario A: In an existing chat

  1. Open a thread with conversation history on an iPhone (in the native iOS app or in Safari).
  2. Tap the thread composer to focus and bring up the software keyboard.
  3. Paste or type a multi-line message (15–20+ lines).
  4. Observe that the composer takes up the entire space between the top navigation bar and the keyboard, leaving 0px to view previous messages.
  5. Attempt to scroll down inside the composer to reach the bottom, tap at the end of the text, or tap the microphone button.

Scenario B: In a new chat ("New thread" / root-compose)

  1. Tap "New thread" on an iPhone.
  2. Type or paste a long prompt.
  3. Observe that with calc(70dvh - 3rem), the composer card expands even further (~550px), pushing the microphone and submit buttons completely off-screen beneath the keyboard.
  4. Attempt to scroll down to place the cursor at the end to dictate via microphone.

Expected vs actual

Expected:
1. The composer and its action toolbar (including mic and submit buttons) remain fully visible above the software keyboard in both thread and new-chat layouts.
2. The user can scroll inside the promptbox to easily place the cursor anywhere (including the very end) and tap the microphone button.
3. Swiping the message timeline blurs the composer and dismisses the keyboard (keyboardDismissMode="on-drag"), freeing the entire screen to read past messages, or a "Done" / collapse button is available.

Actual:
1. In both existing chats (50dvh) and new chats (70dvh), the composer grows taller than the visible viewport above the keyboard; action buttons (microphone, model selector, send) are pushed beneath the keyboard.
2. Single-finger swipe inside the text area moves the text caret instead of scrolling the container.
3. The chat history is completely occluded (0–20px visible). There is no "Done" button on the keyboard, and scrolling the timeline does not dismiss the keyboard, trapping the user in the focused composer.

Root Cause Analysis

1. dvh does not shrink on iOS when the virtual keyboard is open

In apps/app/src/components/promptbox/ComposerEditorSlot.tsx:

const COMPOSER_EDITOR_MAX_HEIGHT_BY_LAYOUT: Record<ComposerEditorLayout, string> = {
  thread: "calc(50dvh - 3rem)",
  "root-compose": "calc(70dvh - 3rem)",
};

Per W3C CSS Values and Units Level 4 spec, dvh (Dynamic Viewport Height) is not affected by the virtual keyboard.

  • In existing threads (50dvh - 3rem), editor slot grows to ~377px.
  • In new chats (70dvh - 3rem), editor slot grows to ~547px!
  • When the iOS virtual keyboard appears (~340px), visible viewport height drops to ~510px.
  • Deducting top navigation header (~50px) and safe areas leaves only ~440px.
  • In new chats, a 547px editor + 70px card toolbar = ~617px, which exceeds the available 440px viewport by ~177px, guaranteeing that the microphone button, attachments, and send button are pushed beneath the keyboard.

2. Timeline occlusion and keyboard trap in @bb/mobile

In apps/mobile/src/screens/webview/ProfileWebViewScreen.tsx:

<ShellWebView
  contentInsetAdjustmentBehavior="never"
  automaticallyAdjustContentInsets={false}
  hideKeyboardAccessoryView // <--- Hides native iOS "Done" accessory bar!
  ...
/>
  • Setting hideKeyboardAccessoryView removes the standard iOS keyboard accessory toolbar where the user normally taps "Done" to dismiss the keyboard.
  • In apps/app/src/components/ui/bottom-anchored-scroll-body.tsx, touch events on the timeline (touchstart, touchmove) mark scroll intent but never call activeElement.blur().
  • Consequently, while typing/composing, the keyboard stays up indefinitely, the composer occupies the entire visible area, and the chat history cannot be read.

3. Touch scroll trapping in contenteditable (ProseMirror)

When .ProseMirror is focused, WebKit captures vertical single-finger touch gestures for text caret navigation / text selection rather than delegating pan gestures to the overflow scroll container ([data-promptbox-editor-scroll]).


Proposed Solution / PR Blueprint

Fix 1: Dynamically clamp maxHeight by window.visualViewport.height on mobile

In apps/app/src/components/promptbox/ComposerEditorSlot.tsx:

function useVisualViewportHeight(): number | null {
  const [height, setHeight] = useState<number | null>(() =>
    typeof window !== "undefined" && window.visualViewport ? window.visualViewport.height : null
  );

  useEffect(() => {
    const vv = window.visualViewport;
    if (!vv) return;
    const update = () => setHeight(vv.height);
    vv.addEventListener("resize", update);
    return () => vv.removeEventListener("resize", update);
  }, []);

  return height;
}

In ComposerEditorSlot:

const visualViewportHeight = useVisualViewportHeight();

// When virtual keyboard is open on small screens (< 650px visual viewport),
// clamp maxHeight to 35% of the visible viewport so composer + bottom action bar (mic, model, send) fit comfortably in both thread and root-compose layouts.
const dynamicMaxHeight = visualViewportHeight && visualViewportHeight < 650
  ? `${Math.max(120, Math.floor(visualViewportHeight * 0.35))}px`
  : COMPOSER_EDITOR_MAX_HEIGHT_BY_LAYOUT[layout];

Apply to style:

style={{
  minHeight: isCompactLayout ? "48px" : `${minHeight}px`,
  height: isCompactLayout ? "48px" : undefined,
  maxHeight: isCompactLayout ? "48px" : dynamicMaxHeight,
}}

Fix 2: Dismiss keyboard on timeline scroll (chat history reading)

In apps/app/src/components/ui/bottom-anchored-scroll-body.tsx:
When the user drags the timeline to read past messages, dismiss the keyboard so the timeline gets the full screen:

const markTouchMoveScrollIntent = useCallback(() => {
  markUserScrollIntent();
  // Dismiss software keyboard if the user starts dragging the chat history
  if (
    document.activeElement instanceof HTMLElement &&
    document.activeElement.closest("[data-app-composer]")
  ) {
    document.activeElement.blur();
  }
}, [markUserScrollIntent]);

And in apps/mobile/src/screens/webview/ProfileWebViewScreen.tsx:
Add keyboardDismissMode="on-drag" to <WebView> so native scroll gestures also drop the keyboard.

Fix 3: Enable smooth touch scrolling on iOS & Auto-scroll on paste

In apps/app/src/components/promptbox/ComposerEditorSlot.tsx:

className={cn(
  "w-full overflow-y-auto bg-transparent px-4 pb-1 pr-14 pt-3 outline-none",
  "touch-pan-y [-webkit-overflow-scrolling:touch]",
  COARSE_POINTER_TEXT_BASE_CLASS,
  "leading-relaxed",
  isCompactLayout && "h-12 overflow-hidden pb-0 pr-14 pt-0",
)}

Auto-scroll to bottom on paste:

useEffect(() => {
  if (!editor) return;
  const handlePaste = () => {
    requestAnimationFrame(() => {
      if (scrollContainerRef.current) {
        scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight;
      }
    });
  };
  editor.view.dom.addEventListener("paste", handlePaste);
  return () => editor.view.dom.removeEventListener("paste", handlePaste);
}, [editor, scrollContainerRef]);

What you ruled out

  • Ruled out bb-plugin-beautiful-chat and other UI plugins: verified against clean BB web CSS.
  • Ruled out desktop browsers (macOS / Linux / Windows): reproducible exclusively on touch devices with virtual software keyboards (iOS Safari and @bb/mobile).

Checks

  • Traced and verified against apps/app/src/components/promptbox/ComposerEditorSlot.tsx, apps/app/src/components/ui/bottom-anchored-scroll-body.tsx, and apps/mobile/src/screens/webview/ProfileWebViewScreen.tsx on main.
  • Covers both thread layout (50dvh) and new-chat root-compose layout (70dvh), plus voice dictation caret positioning.
  • Includes complete reproduction, root cause geometry analysis, and ready-to-implement code fix.

AGENT GENERATED

Investigation thread: thr_rj96urndqv

Activity

  1. added theissue type on Sep 21, 2026
  2. added
    ui
    mobile
    partial-repro
    on Sep 21, 2026
  3. bb-slop-cop commented on Sep 22, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · High priority · Medium effort · ui, mobile (all missing values applied).
    • Report: Reproduction and root-cause report
    • Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium · Label: partial-repro.
    • Finding: The editor uses a viewport-based height cap while the shell tracks the visual viewport. A real component probe exceeded a synthetic height budget in root-compose; the thread probe fit. Both results repeated in a second clean checkout. Full iOS keyboard, touch scrolling, and dictation behavior remain unverified.
    • No PR: The full reported failure and a qualifying failing regression test were not established.

    AGENT GENERATED

  4. slowerhard-alt commented on Nov 7, 2026

    @slowerhard-alt

    Still reproducible on 0.49.0 after #7061, and here is why the new cap does not hold.

    Environment

    • BB 0.49.0 (bb-app 0.49.0), thread view, iOS Safari, 15-line draft, keyboard open
    • Measurements in browser emulation: 390×844, mobile + coarse pointer, visualViewport.height forced to 516 with offsetTop 0 (iOS keeps the layout viewport when the keyboard opens)

    Root cause

    bb--composer renders the editor scroll container with an inline style:

    max-height: min(calc(var(--bb-shell-height) * 0.5 - 3rem), var(--composer-editor-available-height, 100dvh))
    

    --composer-editor-available-height is written by the composer on that same container from its keyboard state:

    let A = () => {
      let J = x.offsetHeight - E.offsetHeight; // shell minus sidebar
      x.style.setProperty("--composer-editor-available-height", `${c - J}px`);
    };

    On iOS --bb-shell-height stays 100dvh and innerHeight stays the full height. In the mobile layout the sidebar has no height, so J is ~0 and the published value is the full shell height (844px). The min() then resolves to 422px (= 50dvh - 3rem). When nothing is published, var() falls back to 100dvh — same result.

    So the 100dvh fallback inside var() makes #7061 ineffective on this path: a missing or too-large value degrades to the full screen, not to the visible area.

    Measurements

    • --bb-shell-height: 100dvh, innerHeight 844, visualViewport.height 516
    • Value on :root: unset; on the editor container: 844px (or absent)
    • Editor container max-height / height: 374 / 408 px; composer form height 447 px, top 69 → covers the thread from 69 to 516
    • Forcing the value to 516px on :root and removing the inline one: editor cap 210 px, composer bottom lands exactly on the visible bottom (456), and the thread stays visible

    Suggestion

    1. Derive the cap from the visual viewport, e.g. min(calc(min(var(--bb-shell-height), <visual-height>) * 0.5 - 3rem), …), or drop the 100dvh fallback.
    2. Publish --composer-editor-available-height on an ancestor (:root or the shell) instead of on the container that consumes it, so one value serves both the reset and keyboard-open states.
    3. The calc(70dvh - 3rem) cap in root-compose likely needs the same change.

    This is the same failure as reported here, just observed after the #7057/#7061 fix; please treat it as evidence that #7061 does not cover the iOS path where the layout viewport does not shrink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    mobilepartial-reproui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions