Skip to content

bug: ion-checkbox don't let interact with label #29304

Closed as not planned
Closed as not planned

Description

@JEricaM

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

Adding a link inside the checkbox label should let the user open the link.

Expected Behavior

A link/click inside a label in checkbox should work correctly.

Steps to Reproduce

Add a ion.checkbox like that

<ion-checkbox
                                        value={value}
                                        name='name'
                                        onIonChange={(e) => this.handleChangeCheck(e)}
                                        label-placement="end">
                                        <div class="ion-text-wrap">My text <a href="https://google.it"> click here</a></div>
                                    </ion-checkbox>

If I click on the link part of the label the href don't triggers, instead only works onIonChange.

Code Reproduction URL

https://d6xspp.stackblitz.io

Ionic Info

Ionic:

Ionic CLI : 7.1.1

Utility:

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

System:

NodeJS : v18.15.0
npm : 9.5.0
OS : macOS Unknown

Additional Information

No response

Activity

  1. liamdebeasi commented on Apr 9, 2024

    @liamdebeasi
    Contributor

    Thanks for the report. This can be achieved by calling stopPropagation when the link is clicked. We've had this question asked a few times before, so I decided to add an example to our documentation on how to do this.

    I've opened ionic-team/ionic-docs#3584 to add this demo. Here is a preview of the docs: https://ionic-docs-git-checkbox-link-ionic1.vercel.app/docs/api/checkbox#links-inside-of-labels

    I am going to close this since this is already achievable in Ionic, but let me know if you have questions.

  2. JEricaM commented on Apr 9, 2024

    @JEricaM
    Author

    thank you so much, the example in the doc it's perfect!

  3. ionitron-bot commented on May 9, 2024

    @ionitron-bot

    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.

  4. locked and limited conversation to collaborators on May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions