ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
497 stars 574 forks source link

Error when locking the orientation to portait while device is held in landscape #2100

Open Alarson93 opened 3 months ago

Alarson93 commented 3 months ago

Bug Report

Plugin(s)

"@capacitor/screen-orientation": "^6.0.0",

Capacitor Version

Installed Dependencies:

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

Platform(s)

iOS

Current Behavior

I lock the orientation to Portrait from the root component. I want the user to sign their name via the in-app browser (via the Browser plugin), so I unlock the orientation before presenting that screen. I have a browserFinished that locks the device to portrait once the user dismisses the in-app browser.

Everything functions as expected - other screens are locked in portrait but the user can rotate the device when viewing the signing screen. Dismissing the in-app browser while in landscape orientation brings us back to the main web app and switches the orientation to portrait.

However, I do get the following error: None of the requested orientations are supported by the view controller. Requested: portrait; Supported: landscapeLeft

Expected Behavior

I would expect to not get the error.

Code Reproduction

await screenOrientationPluginWrapper.lock({ orientation: 'portrait' })

But only while the device is rotated.

Other Technical Details

Commenting out this line seems to resolve the issue: https://github.com/ionic-team/capacitor-plugins/blob/20b9e26b1b0b10228c85049b4093a5ed9cfe64c5/screen-orientation/ios/Sources/ScreenOrientationPlugin/ScreenOrientation.swift#L37C1-L39C22

Additional Context

This issue sound very similar to this issue from Capawesome's version of the plugin: https://github.com/capawesome-team/capacitor-plugins/issues/100

ionitron-bot[bot] commented 3 months ago

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.