Skip to content

fix(keyboard): listen on correct events for keyboard lifecycle - #27569

Merged
sean-perkins merged 2 commits into
mainfrom
FW-4465
May 31, 2023
Merged

sean-perkins merged 2 commits into
mainfrom
FW-4465

Conversation

@liamdebeasi

@liamdebeasi liamdebeasi commented May 30, 2023 •

Copy link
Copy Markdown
Contributor

Issue number: resolves #27558


What is the current behavior?

The keyboard lifecycle util was always listening on visual viewport events even when in native environments. The visual viewport API is not reliable due to how the Ionic webview customizes how it resizes. We should only be listening on the native keyboard events in native environments.

ionic-team/capacitor#3730

https://github.com/ionic-team/capacitor-plugins/blob/2e883f39329626062bcf876fe7d424432617229d/keyboard/ios/Plugin/Keyboard.m#L90-L98

What is the new behavior?

  • Keyboard lifecycle util listens on native keyboard events only when in native environment

Does this introduce a breaking change?

  • Yes
  • No

Other information

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@liamdebeasi liamdebeasi changed the title Fw 4465 fix(keyboard): listen on correct events for keyboard lifecycle May 30, 2023
@github-actions github-actions Bot added the package: core @ionic/core package label May 30, 2023
@liamdebeasi
liamdebeasi marked this pull request as ready for review May 30, 2023 13:54
@liamdebeasi
liamdebeasi requested review from a team and sean-perkins and removed request for a team May 30, 2023 21:10
@sean-perkins
sean-perkins added this pull request to the merge queue May 31, 2023
Merged via the queue into main with commit 7871210 May 31, 2023
@sean-perkins
sean-perkins deleted the FW-4465 branch May 31, 2023 19:09
liamdebeasi added a commit that referenced this pull request Jun 15, 2023
…able but the Keyboard plugin is not (#27655)

Issue number: resolves #27654

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

When Capacitor and the Keyboard plugin are available,
`Keyboard.getEngine()` returns an object:
https://github.com/ionic-team/ionic-framework/blob/d3232dcc007738fae851660bd818c8056b48b7d2/core/src/utils/native/keyboard.ts#L19

When Capacitor is _not_ available this method returns `undefined`.

However, when Capacitor is available but the Keyboard plugin is not,
`Keyboard.getEngine()` returns `false`.

In #27569 I fixed a
bug where the wrong listeners were being used to emit keyboard lifecycle
events. However, I did not know that method can return `false`, and our
tests only account for the `undefined` or defined edge cases. As a
result, if you are using Capacitor in an app that is deployed to the
browser then the visual viewport Ionic keyboard events never fire.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Visual viewport Ionic keyboard events fire in browser

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: keyboard events listens on visual viewport when in capacitor/cordova

2 participants