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

bug: ion-item multiple-inputs does not work when inputs wrapped

Open elinake opened this issue 1 year ago • 4 comments

Prerequisites

Ionic Framework Version

  • [ ] v4.x
  • [X] v5.x
  • [ ] v6.x
  • [ ] Nightly

Current Behavior

When I have a button and checkbox inside ion-buttons in ion-item, checkbox width is forced so that it covers the button too, so that button clicks are regarded as checkbox clicks.

ion-checkbox-error ion-checkboxx

The only slightly related issue I could find is this bugfix from Ionic 4 https://github.com/ionic-team/ionic-framework/issues/15850 where @brandyscarney links a workaround for button + input, but that workaround is not working for Ionic 5.

Expected Behavior

It should be possible to affect checkbox's width so that native element is not forced to be wider than the actual checkbox.

Steps to Reproduce

If I wrap the elements with div instead of ion-buttons, issue persists. If I don't wrap the two elements in anything, then it works correctly. I managed to achieve the desired style by slot="end" and adding individual css classes, but it would be more convenient if it was possible to use any kind of wrapping.

<ion-item>
      <ion-buttons> </ion-buttons>
      <ion-label>wrong</ion-label>
      <ion-buttons slot="end">
        <ion-button size="small" fill="clear">
          <ion-icon name="information-circle"></ion-icon>
        </ion-button>
        <ion-checkbox></ion-checkbox>
      </ion-buttons>
    </ion-item>

Code Reproduction URL

https://stackblitz.com/edit/ionic-5-angular-10-start-template-lu7yap?file=src/app/app.component.html

Ionic Info

Ionic:

Ionic CLI : 6.18.1 Ionic Framework : @ionic/angular 5.8.4 @angular-devkit/build-angular : 12.2.13 @angular-devkit/schematics : 12.2.13 @angular/cli : 12.2.13 @ionic/angular-toolkit : 5.0.3

Utility:

cordova-res : not installed globally native-run : 1.5.0

System:

NodeJS : v16.10.0 (C:\Program Files\nodejs\node.exe) npm : 7.24.0 OS : Windows 10

Additional Information

No response

elinake avatar Aug 05 '22 10:08 elinake

Thanks for the issue. We do not recommend using ion-buttons to wrap non ion-button elements, so I would not expect the examples you provided to work as expected.

That being said, there's definitely some incorrect behaviors when combining elements with form controls inside of ion-item. Here is one example: https://github.com/ionic-team/ionic-framework/issues/23331

We have a proposal up to change how form controls are used which should help make these components easier to work with. We'd love any feedback you have on the discussions below:

Checkbox, radio, range, toggle: https://github.com/ionic-team/ionic-framework/discussions/25660 Input, textarea, select: https://github.com/ionic-team/ionic-framework/discussions/25661

liamdebeasi avatar Aug 05 '22 13:08 liamdebeasi

@liamdebeasi Thanks for the links, I'll check them out. I also mentioned that the same issue applies also when I wrap the components in div, do you have a comment on that?

elinake avatar Aug 09 '22 06:08 elinake

That change seems to be strictly for cases when you have only one functionality, ie. all items have label and radio button. However, my issue is with having multiple functionalities in the same item/row: label, then button and checkbox. If I have to continue using

<ion-item>
 label
 button
checkbox
</ion-item>

Will the breaking elements of forms still exists in item?

elinake avatar Aug 09 '22 07:08 elinake

Multiple items will also be fixed with this. Specifically, we will be removing this logic: https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/item/item.tsx#L237. This is the code that triggers the multiple interactive issue you are running into.

The item component is tightly coupled with form components. The changes I described above will allow us to de-couple item from the form components.

liamdebeasi avatar Aug 09 '22 14:08 liamdebeasi

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 09 '22 12:09 ionitron-bot[bot]