Skip to content

fix(ios): ignore keyboard show events when running as an iOS app on Mac - #86

Open
SaebAmini wants to merge 1 commit into
ionic-team:mainfrom
SaebAmini:fix/ios-app-on-mac-keyboard
Open

SaebAmini wants to merge 1 commit into
ionic-team:mainfrom
SaebAmini:fix/ios-app-on-mac-keyboard

Conversation

@SaebAmini

Copy link
Copy Markdown

Description

Early-return from onKeyboardWillShow: and onKeyboardDidShow: when NSProcessInfo.processInfo.isiOSAppOnMac is true.

Context

When an iPad app runs on Apple Silicon Macs ("Designed for iPad", including installs from the Mac App Store), there is no virtual keyboard, but UIKit still posts UIKeyboardWillShowNotification / UIKeyboardDidShowNotification whenever a text input gains focus.

Because userInterfaceIdiom is .pad on Mac, the plugin goes through the iPad/Stage Manager path and derives a "keyboard height" from the Mac window/screen geometry. With resize set to ionic, body or native, this shrinks the web content by that amount. The result is the layout shifting up and an empty area appearing at the bottom of the window for a keyboard that doesn't exist.

Since a virtual keyboard never appears on Mac, ignoring these notifications there is the simplest correct behaviour. isiOSAppOnMac is available from iOS 14, below the plugin's iOS 15 minimum.

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Platforms affected

  • Android
  • iOS
  • Web

Tests

Tested with an Ionic/Capacitor 8 app using resize: 'ionic', run from Xcode on "My Mac (Designed for iPad)". Before the change, focusing any input shrinks ion-app and leaves an empty band at the bottom of the window. After the change, the layout stays put. iPhone/iPad are unaffected because the guard is only true when running on a Mac.

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.

1 participant