iOS: keyboardWillHide/keyboardDidHide are evaluated before the page loads on iPad, logging "JS Eval error" twice at launch
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 57/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- ios, typescript
- Ambito
- mobile
Direzione di ricerca
Start with the iOS keyboard plugin’s Keyboard.m handlers for keyboardWillHide and keyboardDidHide, then compare how CapacitorBridge handles scene lifecycle events before the page loads. Reproduce on an iPad simulator and confirm the launch errors disappear while keyboard events still work after the page loads.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 8.6.0
@capacitor/core: 8.6.0
@capacitor/android: 8.6.0
@capacitor/ios: 8.6.0
Installed Dependencies:
@capacitor/cli: 8.6.0
@capacitor/core: 8.6.0
@capacitor/android: 8.6.0
@capacitor/ios: 8.6.0
[success] iOS looking great! 👌
[success] Android looking great! 👌
@capacitor/keyboard 8.0.6, the latest. Its Keyboard.m on main has the same handlers.
Platform(s)
iOS: iPad. Seen on the iPad Air 11-inch (M4) simulator, iOS 27.2 (Xcode 27.2). Not seen on the iPhone 18 Pro simulator.
Current Behavior
On every cold launch on iPad, the console shows two eval errors before the web view has loaded:
⚡️ Loading app at capacitor://localhost...
⚡️ JS Eval error A JavaScript exception occurred
⚡️ JS Eval error A JavaScript exception occurred
⚡️ WebView loaded
iOS posts UIKeyboardWillHideNotification and UIKeyboardDidHideNotification at launch while the web view is still loading its first page. onKeyboardWillHide: (through its timer) and onKeyboardDidHide: then call [self.bridge triggerWindowJSEventWithEventName:…]. That evaluates window.Capacitor.triggerEvent('keyboardWillHide', 'window') and …('keyboardDidHide', 'window') in a document where window.Capacitor is not defined yet, so both throw.
With an NSLog added at the top of both handlers, two cold launches logged:
⚡️ Loading app at capacitor://localhost...
[kbd-probe] willHide, loading=1
[kbd-probe] didHide, loading=1
⚡️ JS Eval error A JavaScript exception occurred
⚡️ JS Eval error A JavaScript exception occurred
⚡️ WebView loaded
(loading is self.webView.isLoading.)
The events are lost, which is harmless: the page does not exist yet, and the keyboard is hidden when it loads. But the two error lines show up on every launch, and they look like a bug in the app.
Expected Behavior
No eval error at launch. Keyboard events that arrive before the page can receive them are dropped quietly. CapacitorBridge 8.6 already does this for the scene lifecycle events (triggerSceneLifecycleJSEvent: on a cold start willEnterForeground is posted "before window.Capacitor has been defined… and surfaces as a 'JS Eval error' in the log", so it is dropped).
Code Reproduction
I haven't made a separate sample app. Seen in an Ionic Angular app on Capacitor 8.6's Swift Package Manager iOS template with @capacitor/keyboard (no keyboard config, so resize mode native). The handlers involved run the same way in any app:
- Install the plugin in a Capacitor 8 app and
npx cap sync ios. - Run the app on an iPad simulator (iPad Air 11-inch (M4), iOS 27.2) with the console attached (
xcrun simctl launch --console-pty <device> <bundle id>). - Read the two "JS Eval error" lines between "Loading app" and "WebView loaded".
Other Technical Details
Xcode 27.2, iOS 27.2 simulator runtime, macOS 26.6 on Apple silicon. Not checked on a physical iPad.
Additional Context
A possible fix: in the will/did hide (and show) handlers, skip triggerWindowJSEventWithEventName: while the web view has not loaded a page yet, as the bridge does. Another option is to guard the evaluated script (window.Capacitor && window.Capacitor.triggerEvent(…)). notifyListeners: is fine, since no listener exists before the page loads.
- Lingua principale
- TypeScript
- Stelle
- 6
- Fork
- 24
- Merge medio
- 2g 4h
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ionic-team/capacitor-keyboard
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
ionic-team/capacitor-keyboard#79 · 1 commento · 1 reazione ·
-
Inconsistent Keyboard Height on Android during WindowInsetsAnimation (Proposed Patch)Forse già presa @lincolnthree l’ha presa 89 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
ionic-team/capacitor-keyboard#80 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 65/100
Tutte le issue di ionic-team/capacitor-keyboard
Issue simili
-
bug P3
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno
-
feat(ai): add markdown checklist export and copy-to-clipboard button to ActionItemSynthesizer drawerApertaai enhancement feature feature-request good-issue L1 level 1 needs-review wocs
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SatyamPandey-07/WorkSphere#8149 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
Client execution contract accepts a grant the code never takesForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea: client enhancement priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensro-dev/opensro#3808 ·
I maintainer di solito rispondono entro 1 giorno
-
bug ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
mithilp/keybuddies#66 ·