Skip to content

fix(ios): prevent black QuickType bar when using Magic Keyboard on iPad + Fix Keyboard on iOS 26#52

Merged
theproducer merged 13 commits into
ionic-team:mainfrom
Daniele-rolli:main
Jun 4, 2026
Merged

fix(ios): prevent black QuickType bar when using Magic Keyboard on iPad + Fix Keyboard on iOS 26#52
theproducer merged 13 commits into
ionic-team:mainfrom
Daniele-rolli:main

Conversation

@Daniele-rolli

Copy link
Copy Markdown
Contributor

Context

On iPads with a hardware keyboard (e.g., Magic Keyboard), iOS still fires UIKeyboardWillShow / UIKeyboardDidShow notifications even when no software keyboard is displayed. Only the QuickType suggestion bar appears at the bottom of the screen.
Currently, Capacitor interprets these events as a "real keyboard," resizing the WKWebView and causing visual glitches such as a black bar below the webview.

On iOS 26, a similar issue occurs with liquid glass the new keyboard is transparent with rounded edges, which can render a black box underneath.

iPad Example

Before After
iPad Before iPad After

iPhone Example

Before After
Simulator Screenshot - iPhone 16e - 2025-09-08 at 19 35 03 Simulator Screenshot - iPhone 16e - 2025-09-08 at 22 09 28

Solution

A height threshold guard was added in onKeyboardWillShow and onKeyboardDidShow in the iOS KeyboardPlugin:

  • If UIDevice.userInterfaceIdiom == .pad and keyboardHeight < 100px:

    • Treat the event as a QuickType bar, not a real keyboard.
    • Do not resize the WKWebView.
    • Fire JS events with keyboardHeight = 0 to indicate “no real keyboard.”
  • Otherwise, continue with normal resizing behavior.

Additional improvements:

  • WebView background is transparent, and its color is forced to match the DOM body via updateBackdropColorFromDOM.

Benefits

  • iPad + Magic Keyboard: no unnecessary resize, no black bar.
  • iPad + software keyboard: normal resize works as expected.
  • iPhone: keyboard backdrop displays the same color as DOM

@theproducer theproducer self-assigned this Apr 8, 2026
@theproducer theproducer self-requested a review April 8, 2026 16:54

@theproducer theproducer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Daniele-rolli Hello! Thanks for this, we've been running into similar issues that you've detailed here. I left some comments and suggestions to your PR.

Comment thread ios/Sources/KeyboardPlugin/Keyboard.m Outdated
Comment thread ios/Sources/KeyboardPlugin/Keyboard.m
@theproducer theproducer requested a review from a team April 9, 2026 15:37
@theproducer theproducer requested a review from a team May 19, 2026 14:07
@OS-pedrogustavobilro OS-pedrogustavobilro self-assigned this May 27, 2026

@OS-pedrogustavobilro OS-pedrogustavobilro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theproducer leaving a few comments of things I noticed.

Comment thread ios/Sources/KeyboardPlugin/Keyboard.m Outdated
Comment thread ios/Sources/KeyboardPlugin/Keyboard.m Outdated
Comment thread ios/Sources/KeyboardPlugin/Keyboard.m Outdated
@theproducer theproducer merged commit 068f643 into ionic-team:main Jun 4, 2026
8 checks passed
capacitor-bot pushed a commit that referenced this pull request Jun 16, 2026
## [8.0.4](v8.0.3...v8.0.4) (2026-06-16)

### Bug Fixes

* **android:** reset WebView height when keyboard hides without animation ([#60](#60)) ([f2e9cd2](f2e9cd2))
* **ios:** prevent black QuickType bar when using Magic Keyboard on iPad + Fix Keyboard on iOS 26 ([#52](#52)) ([068f643](068f643))
@OS-pedrogustavobilro

Copy link
Copy Markdown
Contributor

@Daniele-rolli this PR was merged in @capacitor/keyboard@8.0.4. Note however that this code differs from what you originally opened. Because of some points raised in this PR internally by the team, this fix is really rather an opt-in functionality (that may become default in a future major version).

So to apply the fix in its full capacity, one needs to add autoBackdropColor as auto in capacitor config file.

Thanks for the PR! Let us know if you have any questions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants