ion-input requires two clicks inside ion-item :V2 RC4
Ionic version: (check one with "x") [ ] 1.x [x] 2.x RC4
I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior: ion-input requires two taps to fire (click) event
I have an ion-input, besides an ion-label, inside an ion-item, inside a form, inside an ion-list. I have a (click) event tied to that input, as it's read only (I have it open up a modal). The input works find when running on desktop browser, but on iPhone 6 device the first click seems to blur the input but a second tap is required to fire the (click) event
Expected behavior: I would expect a single click on the input to fire the (click) event
Steps to reproduce: Issue does not present itself when running in desktop browser, only on device. Relevant code below should demonstrate what's going on. 100% reproducibility with the below
Related code:
Example in a form with floating label
<ion-list>
<form ng-submit="addOrUpdate()">
<ion-item>
<ion-label floating>Type</ion-label>
<ion-input type="text" [ngModel]="type?.name" name="type" readonly (click)="selecType()"></ion-input>
</ion-item>
...
Second, less complex example
<ion-list>
<ion-item>
<ion-label>Type</ion-label>
<ion-input tappable type="text" [ngModel]="filters.selectedType?.name" name="type" readonly (click)="selectType()"></ion-input>
</ion-item>
...
Other information: Seems very related to #6944 and #6514. One clue might be that during certain configurations (ex; as a button inside a div) the first click blurs the input and stacks the label, then the second click actually fires the event. Can't figure out how to use that knowledge to make it work though.
Things I have tried but produce the same misbehavior:
- with and without tappable
- moving the (click) event up inside the ion-item instead of on the ion-input
- making the ion-item into a
- wrapping the whole thing in a div and putting the (click) in there
- excluding the form
- all of the above attempts with a (tap) event instead of (click)
I cannot figure out any workaround, which stinks, because this is a critical item in the form for my app, and it's not obvious that the user is required to click twice.
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: 1.9.0
ios-sim version: 5.0.9
OS: macOS Sierra
Node Version: v6.2.0
Xcode version: Xcode 8.2.1 Build version 8C1002
Update; figured out a viable workaround. The issue is still an issue, and should be fixed, but the below seems to satisfy my needs and maintains the same UI/UX for the user.
<button ion-item (click)="selectType()" padding tappable detail-none>
<ion-label *ngIf="type" stacked>Type</ion-label>
<ion-label *ngIf="!type">Type</ion-label>
<ion-label>{{type?.name}}</ion-label>
</button>
Making everything a label and just managing it all manually seems to not upset any of the click events, and the UI of stacked/floating labels works almost perfectly
UX-wise, users expect to be able to edit inputs, and disabled inputs imply that one of their settings forbids editing the input. Perhaps you could put a button at the end of the item's row that allows the user to edit the contents of the input.
@wbhob Thanks for the note Wilson but the readonly really has nothing to do with the issue described. Further... the field is editable, but not by typing. It's a complex object so the click event opens up a modal where they can create/edit/delete/select from those objects. It used to be a select but I just rolled it into a custom modal, basically still just a fancy select though. You can see in my update the behavior; show the label either stacked or not, show the selected type if it exists, then clicking anywhere on the "input" (which in this case is technically a button) opens up the modal for them to select a type.
+1
Try making the ion-item tappable instead. It worked fine for me on 2.0.1
The tappable attribute on the whole ion-item fixed it in my case.
Same issue here with :
<ion-item>
<ion-label>Time</ion-label>
<ion-input type="Time" [(ngModel)]="act.time" name="time"></ion-input>
</ion-item>
Time will need double click to show native time picker no matter if ion item is tappable
The tappable attribute doesn't fix it for me. Ionic 3.12.0
same here
It fixes it for version 2 but not for version 3, can you confirm?
same here. not working in version 3 even the with the tappable attribute.
I have fixed it by writing the following style in my .scss file:
.input-cover{ display: none; } Now i could able to focus on the first input field without any issue.
luckychel You are a crack!
Any news on this issue? I tried the css fix above without any luck? Here is a sample of my form:
<form [formGroup]="contactForm" text-left>
<ion-list>
<ion-item>
<ion-label floating>
First Name
</ion-label>
<ion-input type="text" formControlName="firstName"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>
Last Name
</ion-label>
<ion-input type="text" formControlName="lastName"></ion-input>
</ion-item>
</ion-list>
</form>
@luckychel Solution work for first input field of a form. What in case of second input?
same for here too
<ion-label class="leaveLabel">Start Date</ion-label>
<ion-item class="regitem">
<ion-input type="date" formControlName="leave_from" required placeholder="Leave From"></ion-input>
</ion-item>
<ion-label class="leaveLabel">End Date</ion-label>
<ion-item class="regitem">
<ion-input type="date" formControlName="leave_to" required placeholder="Leave To"></ion-input>
</ion-item>
I used (tap) instead of (click) on ion-input.
In ionic 3, all above ways are invalid for second input. anyone helps.
This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.
If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know!
Thank you for using Ionic!
Issue moved to: https://github.com/ionic-team/ionic-v3/issues/158