ionic-framework: bug: ion-item padding prevents child ion-input focus
Bug Report
Ionic version:
[ ] 4.x [x] 5.x
Current behavior:
While working with a community member, it was observed that when a floating label and ion-input are nested in an ion-item, users can tap the left padding of the item and it will:
- Animate the floating label to the top
- Present the device keyboard
- Not focus the input field
This behavior was captured for iOS with Ionic Angular 5.2.0.
Expected behavior:
When tapping the padding, it should place the input field in focus in addition to the other actions performed.
Steps to reproduce:
- Create an
ion-itemwith anion-labelandion-inputas children. - Set the
positionof theion-labeltofloating. - Open the app on an iOS device/simulator.
- Tap the far-left of the
ion-item.
Please find a GIF of this behavior towards the bottom of this Issue.
Related code:
Reproduction Application: https://github.com/ehorodyski-ionic/ionic-floating-label-focus-issue
Other information:

Ionic info:
Ionic:
Ionic CLI : 6.10.0
Ionic Framework : @ionic/angular 5.2.0
@angular-devkit/build-angular : 0.901.8
@angular-devkit/schematics : 9.1.8
@angular/cli : 9.1.8
@ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.2.0
@capacitor/core : 2.2.0
Utility:
cordova-res (update available: 0.14.0) : 0.11.0
native-run : 1.0.0
System:
NodeJS : v12.16.1 (/usr/local/bin/node)
npm : 6.14.4
OS : macOS Catalina
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 20 (6 by maintainers)
this might seem like a small issue but can impact UX quite heavy… E.g. when your login form is based of two of these inputs and the user clicks on the password label, the keyboard shows up but the input goes into the void.
Any chance to add this to the 5.3.0 milestone?
We can confirm this as well and it is impacting users of our app. A fix would be very much appreciated
Hi all, I’ve created a dev build with a potential fix if you could test it out. During my testing it seems to fix this bug:
Thanks!
I have the same issue if clicking to the right of the label text (over the input) and on the label text. Clicking anywhere on the ion-item should focus the input.
I have ionic version 5.2.1. Testet on iOS.
In our app it seems to happen when clicking anywhere on the
ion-itemthat wraps theion-input(including theion-labelwhich for us is not configured as a floating label). We do not see it happen on Android nor desktop Chrome.From my testing in our app, Ionic v5.1.1 is the version where the behavior was introduced where clicking on the
ion-itemoutside of theion-input(such as on anion-label) automatically puts focus in theion-input. Like @liamdebeasi, I was suspicious of thedelegatesFocusthat was introduced being the change which introduced this behavior.It appears this behavior is due
delegatesFocus: truein https://github.com/ionic-team/ionic/blob/master/core/src/components/item/item.tsx#L25.delegatesFocusis a property that can be set on shadow roots. When this istrue, focus events are delegated to the focusable element inside of the shadow dom.For some reason, this is the native
inputinside ofion-inputrather thanion-inputitself.