You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are developing an iPad app that primarily wraps our web app. Notably, we are not using Ionic for this project. I'm looking for feedback on our approach to handling the keyboard appearance, particularly focusing on scrolling and resizing when the keyboard is visible or hidden.
Initial situation
By default, wrapping a website in a Capacitor app results in a page-like behavior, as shown in this example (https://share.cleanshot.com/Ss21Wklg). The entire content can be scrolled, which doesn't resemble a typical app experience.
Integrating @capacitor/keyboard
We can fix this issue by adding the Keyboard plugin. Simply integrating this plugin disables the system scrolling and fixes the content in place.
Issues with native resizing mode
I experimented with the native resizing mode, but it didn't provide the desired results. Dismissing the keyboard left a large white gap. Should I have given this option more consideration?
Using body as the Resizing Mode
In our iOS app, we utilize ionic resizing, but our current app doesn't rely on Ionic. To address this, I created a custom component called CapacitorScreen to serve as an alternative to IonicApp.
Unfortunately, the native side of @capacitor/keyboard doesn't provide a setting for resizing custom elements – only body or ionic options are available.
To work around this limitation, we observed changes to the body element's style. Here's a snippet of our implementation:
The spacer is added just before the keyboard becomes visible, allowing us to start scrolling to the element immediately after focusing on the input.
When a user focuses on an input, the CapacitorInput component calculates whether scrolling is necessary. If so, it requests the container to scroll to the element via React Context.
Main question
Considering that we're not using Ionic in our app and that we require resizing when the keyboard is shown or hidden, as well as scrolling to focused inputs, does our solution seem like the simplest way to address our problem?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
We are developing an iPad app that primarily wraps our web app. Notably, we are not using Ionic for this project. I'm looking for feedback on our approach to handling the keyboard appearance, particularly focusing on scrolling and resizing when the keyboard is visible or hidden.
Initial situation
By default, wrapping a website in a Capacitor app results in a page-like behavior, as shown in this example (https://share.cleanshot.com/Ss21Wklg). The entire content can be scrolled, which doesn't resemble a typical app experience.
Integrating
@capacitor/keyboard
We can fix this issue by adding the Keyboard plugin. Simply integrating this plugin disables the system scrolling and fixes the content in place.
Issues with
native
resizing modeI experimented with the native resizing mode, but it didn't provide the desired results. Dismissing the keyboard left a large white gap. Should I have given this option more consideration?
Using
body
as the Resizing ModeIn our iOS app, we utilize
ionic
resizing, but our current app doesn't rely on Ionic. To address this, I created a custom component calledCapacitorScreen
to serve as an alternative toIonicApp
.Unfortunately, the native side of
@capacitor/keyboard
doesn't provide a setting for resizing custom elements – onlybody
orionic
options are available.To work around this limitation, we observed changes to the body element's style. Here's a snippet of our implementation:
Other approaches considered:
height: 100%
. However, this would require more extensive rewriting of our app.@capacitor/keyboard
and adding a custom-element resizing mode. Would the Capacitor team welcome such a contribution?Scrolling to focused input
To address this, we introduced
CapacitorContainer
andCapacitorInput
components as alternatives toIonContent
andIonInput
.The container component looks like this:
The spacer is added just before the keyboard becomes visible, allowing us to start scrolling to the element immediately after focusing on the input.
When a user focuses on an input, the
CapacitorInput
component calculates whether scrolling is necessary. If so, it requests the container to scroll to the element via React Context.Main question
Considering that we're not using Ionic in our app and that we require resizing when the keyboard is shown or hidden, as well as scrolling to focused inputs, does our solution seem like the simplest way to address our problem?
Beta Was this translation helpful? Give feedback.
All reactions