Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Keyboard is not resized properly when resize mode is changed from native to none #2216

Open
cornelius-behrend opened this issue Oct 22, 2024 · 2 comments

Comments

@cornelius-behrend
Copy link

Bug Report

Plugin(s)

@capacitor/keyboard 6.0.2

Capacitor Version

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

Platform(s)

  • iOS

Current Behavior

When the keyboard is opened with the resize mode native and then the resize mode is switched to none while the keyboard is still open, closing the keyboard results in a black box since the web view is not reseted to its original bounds.

Expected Behavior

Even when changing the resize mode back and forth, the web view should be displayed correctly.

Code Reproduction

This can be i.e. fixed by adding a reset of the frame if the resize mode is "none".


- (void)_updateFrame
{
  CGRect f, wf = CGRectZero;
  UIWindow * window = nil;
    
  if ([[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)]) {
    window = [[[UIApplication sharedApplication] delegate] window];
  }
  
  if (!window) {
    if (@available(iOS 13.0, *)) {
      NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", UIWindowScene.class];
      UIScene *scene = [UIApplication.sharedApplication.connectedScenes.allObjects filteredArrayUsingPredicate:predicate].firstObject;
      window = [[(UIWindowScene*)scene windows] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isKeyWindow == YES"]].firstObject;
    }
  }
  if (window) {
    f = [window bounds];
  }
  if (self.webView != nil) {
    wf = self.webView.frame;
  }
  switch (self.keyboardResizes) {
    case ResizeBody:
    {
      [self resizeElement:@"document.body" withPaddingBottom:_paddingBottom withScreenHeight:(int)f.size.height];
      break;
    }
    case ResizeIonic:
    {
      [self resizeElement:@"document.querySelector('ion-app')" withPaddingBottom:_paddingBottom withScreenHeight:(int)f.size.height];
      break;
    }
    case ResizeNative:
    {
      [self.webView setFrame:CGRectMake(wf.origin.x, wf.origin.y, f.size.width - wf.origin.x, f.size.height - wf.origin.y - self.paddingBottom)];
      break;
    }
    case ResizeNone:
    {
      [self.webView setFrame:CGRectMake(wf.origin.x, wf.origin.y, f.size.width - wf.origin.x, f.size.height - wf.origin.y)];
      break;
    }
    default:
      break;
  }
  [self resetScrollView];
}

Other Technical Details

Additional Context

@ionitron-bot ionitron-bot bot added the triage label Oct 22, 2024
@ionitron-bot ionitron-bot bot removed the triage label Oct 22, 2024
@cornelius-behrend cornelius-behrend changed the title iOS: Keyboard is not resizes properly when resize mode is changed from native to none iOS: Keyboard is not resized properly when resize mode is changed from native to none Oct 22, 2024
@Ionitron
Copy link
Collaborator

This issue needs more information before it can be addressed.
In particular, the reporter needs to provide a minimal sample app that demonstrates the issue.
If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks!
Ionitron 💙

@alexgerardojacinto
Copy link
Collaborator

@cornelius-behrend can you provide a GitHub repo with an app where the issue can be replicated?

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

No branches or pull requests

3 participants