ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

ion-input requires two clicks inside ion-item :V2 RC4

Open joshuaohana opened this issue 9 years ago • 20 comments

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

joshuaohana avatar Dec 23 '16 20:12 joshuaohana

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

joshuaohana avatar Dec 23 '16 22:12 joshuaohana

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 avatar Dec 24 '16 15:12 wbhob

@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.

joshuaohana avatar Dec 24 '16 16:12 joshuaohana

+1

kabus202 avatar Feb 22 '17 11:02 kabus202

Try making the ion-item tappable instead. It worked fine for me on 2.0.1

wbhob avatar Feb 22 '17 13:02 wbhob

The tappable attribute on the whole ion-item fixed it in my case.

darkoromanov avatar Sep 05 '17 13:09 darkoromanov

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

oxykill avatar Oct 03 '17 12:10 oxykill

The tappable attribute doesn't fix it for me. Ionic 3.12.0

adolfov avatar Oct 09 '17 13:10 adolfov

same here

sinkz avatar Oct 12 '17 17:10 sinkz

It fixes it for version 2 but not for version 3, can you confirm?

darkoromanov avatar Oct 21 '17 15:10 darkoromanov

same here. not working in version 3 even the with the tappable attribute.

ridwan85 avatar Dec 08 '17 08:12 ridwan85

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 avatar Jan 30 '18 22:01 luckychel

luckychel You are a crack!

willmontiel avatar Feb 06 '18 21:02 willmontiel

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>

NTXAggie avatar Apr 14 '18 01:04 NTXAggie

@luckychel Solution work for first input field of a form. What in case of second input?

sinalkarpradnya avatar Jun 06 '18 05:06 sinalkarpradnya

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>

jaggu07 avatar Aug 05 '18 20:08 jaggu07

I used (tap) instead of (click) on ion-input.

ejulfaey avatar Sep 03 '18 05:09 ejulfaey

In ionic 3, all above ways are invalid for second input. anyone helps.

navylover avatar Nov 12 '18 08:11 navylover

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!

ionitron-bot[bot] avatar Nov 28 '18 22:11 ionitron-bot[bot]

Issue moved to: https://github.com/ionic-team/ionic-v3/issues/158

ionitron-bot[bot] avatar Nov 28 '18 22:11 ionitron-bot[bot]