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

[BUG] onKeyboardShowCb called multiple times with accessory views #176

Closed
rgoldiez opened this issue Feb 17, 2022 · 3 comments
Closed

[BUG] onKeyboardShowCb called multiple times with accessory views #176

rgoldiez opened this issue Feb 17, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rgoldiez
Copy link

Describe the bug
On real devices with a virtual keyboard, this line throws an uncaught exception if an input is focused and then changed with an accessory view.

To Reproduce
Steps to reproduce the behavior:

  1. Create a bottom pane with a text input; make sure that input is going to show the accessory view Keyboard.setAccessoryBarVisible({ isVisible: visible }); if using capacitor with the Keyboard plugin.
  2. Launch the bottom pane and focus on the input (make sure the virtual keyboard is visible)
  3. Type in the input to cause another keyboardWillShow events to fire
  4. See error

Expected behavior
This component is using the keyboardWillShow event to capture the proper breakpoint before the keyboard is shown and then holding on to that breakpoint in prevBreakpoint. However an error is thrown if this is handler is called a second time because the line referenced above does not find a breakpoint (keyboard is already showing and so the pane has been translated already to a new position).

Screenshots
Error: undefined is not an object (evaluating 'Object.entries(this.breakpoints.breaks).find((function(t){return t[1]===e.instance.getPanelTransformY()}))[0]')

Smartphone:

  • Device: iPhones, iPads, and Android devices
  • OS: 15.2 / Android 11 but possibly others
  • Browser: Capacitor / Cordova apps

Additional context
This stackoverflow issue / "solution" describes how the keyboardWillShow can be called multiple times without a keyboardWillHide. One solution could be to track an instance variable so that when the keyboard initially shows the event callback is execute once and not again until the instance variable is cleared by reseting it in the keyboardWillHide callback.

@roman-rr roman-rr self-assigned this Feb 17, 2022
@roman-rr roman-rr added the bug Something isn't working label Feb 17, 2022
@rgoldiez
Copy link
Author

@roman-rr
Copy link
Collaborator

@rgoldiez Thank you for report!
Should be fixed in latest commit, include up/down events with accessory bar.
Please, check it!

@rgoldiez
Copy link
Author

@roman-rr - your changes look good and the error is gone. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants