capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

[Bug]: Initial `ScreenOrientation.orientation()` is wrong on iPad

Open timephy opened this issue 4 months ago • 1 comments

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 7.4.2 @capacitor/core: 7.4.2 @capacitor/android: 7.4.2 @capacitor/ios: 7.4.2

Installed Dependencies:

@capacitor/cli: 7.4.2 @capacitor/core: 7.4.2 @capacitor/android: 7.4.2 @capacitor/ios: 7.4.2

[info] Using Gemfile: RubyGems bundle installed [success] iOS looking great! 👌 [success] Android looking great! 👌

$ pnpm list

dependencies: @capacitor/android 7.4.2 @capacitor/app 7.0.1 @capacitor/core 7.4.2 @capacitor/ios 7.4.2 @capacitor/keyboard 7.0.1 @capacitor/screen-orientation 7.0.1 @capacitor/share 7.0.1 @capacitor/splash-screen 7.0.1 @capacitor/status-bar 7.0.2

devDependencies: @capacitor/assets 3.0.5 @capacitor/cli 7.4.2 @types/node 20.19.8 typescript 5.8.3

Other API Details


Platforms Affected

  • [x] iOS
  • [ ] Android
  • [ ] Web

Current Behavior

  • Tested on iPad (A16)
  • Opened the app in landscape
  • Call to ScreenOrientation.orientation() returns portrait-primary

Expected Behavior

Should return landscape-primary or landscape-secondary

Project Reproduction

Additional Information

No response

timephy avatar Aug 12 '25 08:08 timephy

I’m experiencing this issue on Android as well. After reviewing the code, I noticed that the plugin calls:

activity.getDisplay().getRotation()

However, it doesn’t account for the device’s natural orientation. The current mapping logic only works correctly for phones (natural orientation = portrait). On tablets, where the natural orientation is landscape, the reported orientation values are incorrect.

hieunguyen2211 avatar Sep 11 '25 10:09 hieunguyen2211