Skip to content

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

Open
Daniele-rolli wants to merge 1 commit intoionic-team:mainfrom
Daniele-rolli:main
Open

fix(ios): prevent black QuickType bar when using Magic Keyboard on iPad + Fix Keyboard on iOS 26#52
Daniele-rolli wants to merge 1 commit intoionic-team:mainfrom
Daniele-rolli:main

Conversation

@Daniele-rolli
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Collaborator

@theproducer theproducer left a comment

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 on lines +182 to +191
// Make WKWebView transparent
if (self.webView) {
self.webView.opaque = NO;
self.webView.backgroundColor = UIColor.clearColor;
self.webView.scrollView.backgroundColor = UIColor.clearColor;
}

// Force DOM color on load
[self updateBackdropColorFromDOM];
}
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.

Maybe instead of making the web view transparent, we should set the background color to one set in the Capacitor config?

NSString *configBackgroundColor = [[[self bridge] config] getString:@"backgroundColor"];
    
UIColor *backgroundColor = [self colorFromCssColorString:(NSString *)configBackgroundColor];
if (backgroundColor) {
    [self forceBackdropColor:backgroundColor];
}

And if that's not set, maybe we then resort to pulling from the DOM body?

Comment on lines +89 to +93
- (BOOL)shouldIgnoreResizeForHeight:(double)height {
if (![self isIPad]) return NO;
if (height <= 0.0) return NO;
return (height < QUICKTYPE_IGNORE_THRESHOLD);
}
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.

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

Maybe we shouldn't have iPad be a differentiator in these checks? Theoretically someone could have a bluetooth keyboard connected to an iPhone...

@theproducer theproducer requested a review from a team April 9, 2026 15:37
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.

2 participants