material icon indicating copy to clipboard operation
material copied to clipboard

md-checkbox: links in label do not work

Open epelc opened this issue 11 years ago • 13 comments

When you have a link within an md-checkbox clicking on the link toggles the checkbox instead of opening the link. Example

md-checkbox-link

 <md-checkbox ng-model="user.AcceptedTerms">
    I agree to the <a ui-sref="legal.tos">Terms of Service</a>
</md-checkbox>

I also tried to add ng-click="$event.stopPropagation()" and ng-click="$event.stopPropagation()" to the <a>. It also doesn't work if you use an href instead of ui-sref.

epelc avatar Dec 04 '14 16:12 epelc

@epelc - please use lowerCamelCase name prefixes (@see Issue Submissions)

ThomasBurleson avatar Dec 04 '14 17:12 ThomasBurleson

@ThomasBurleson Sorry about that

epelc avatar Dec 04 '14 17:12 epelc

@epelc - No worries. You are a great contributor; hence my using your submission to set standards/precedence ;-)

ThomasBurleson avatar Dec 04 '14 17:12 ThomasBurleson

@ThomasBurleson Thank you. I hope I can contribute more soon.

epelc avatar Dec 04 '14 17:12 epelc

Note: This should be resolved when refactored approach to checkboxes/radio buttons is implemented.

robertmesserle avatar Jan 28 '15 18:01 robertmesserle

Related issues: #1006 #1007

robertmesserle avatar Jan 28 '15 18:01 robertmesserle

@robertmesserle I just noticed that you can tab to the links but the focus state does not seem to show on the link or the checkbox text.

epelc avatar Mar 02 '15 03:03 epelc

what about this?

leibale avatar Mar 18 '15 17:03 leibale

Guys, any update on this one?

sheaujye avatar Jun 02 '15 04:06 sheaujye

click over the link doesn't work because '.md-label' has 'pointer-events: none;' css rule. my quick fix for now:

md-checkbox .md-label {
    pointer-events: auto;
}
md-checkbox .md-label span {
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

iamgioz avatar Jun 03 '15 14:06 iamgioz

When the link has target="_blank" clicking the link will check the checkbox (with the 0.10 version). I think this should not happen.

See http://plnkr.co/edit/fjXDqbi6U5p6zv9K1AKM?p=preview

Necroskillz avatar Jun 25 '15 14:06 Necroskillz

+1 @Necroskillz

Any update on the fix for this anyone please?

ksgupta avatar Apr 21 '16 02:04 ksgupta

Here is a workaround:

<md-checkbox ng-model="conditions">
    I agree to the 
    <a onclick="window.open('legal.tos')" ng-click="$event.stopPropagation()">
        Terms of Service
    </a>
</md-checkbox>

(you could use $window instead of window if required)

arne-s avatar Apr 29 '16 09:04 arne-s