Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click event on label should be prevented if its child input element is disabled #6949

Closed
polendri opened this issue Feb 11, 2019 · 5 comments
Assignees
Labels
AREA: client FREQUENCY: level 2 SYSTEM: action simulation TYPE: bug The described behavior is considered as wrong (bug).

Comments

@polendri
Copy link

Related to DevExpress/testcafe-hammerhead#1880, where a fix was added to prevent mouse events on elements that have the disabled attribute set (or that have an ancestor for which it's set).

There's an edge case which wasn't considered: it's semantically correct to have a <label> element which contains its related input element, and in this case mouse events on the <label> should be prevented if the input is disabled.

Example:

<label>Do you like peas?
  <input type="checkbox" disabled name="peas">
</label>

In TestCafe 1.0.0 (hammerhead 14.4.12 based on my package-lock.json), this works as expected in Chrome, Edge and IE, but Firefox incorrectly triggers a click event on a label such as the one above. Firefox does not do this when manually clicking the label, so it's specific to Hammerhead.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 11, 2019
@polendri polendri changed the title Click event on label should be prevent if its child input element is disabled Click event on label should be prevented if its child input element is disabled Feb 11, 2019
@LavrovArtem LavrovArtem self-assigned this Feb 13, 2019
@LavrovArtem LavrovArtem added TYPE: bug The described behavior is considered as wrong (bug). AREA: client SYSTEM: action simulation labels Feb 13, 2019
@LavrovArtem
Copy link
Contributor

Thank you for this information! I've reproduced this issue.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 13, 2019
@polendri
Copy link
Author

Thanks for the prompt response/prioritization!

One more situation that causes this issue: <label> has a for attribute which links it to an <input> element, and browser behaviour is to supress click events on the <label> if its for attribute points to a disabled input element. So a click on the <label> in this example should also not trigger an event:

<label for="peas-input">Do you like peas?</label>
<input id="peas-input" type="checkbox" disabled name="peas">

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 20, 2019
@LavrovArtem
Copy link
Contributor

Thank you for the additional information. It is very helpful.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 26, 2019
@AlexKamaev
Copy link
Contributor

Please also take a look at #2902

@pingviini
Copy link

I believe this issue relates also to a following scenario where you have link inside checkbox label. E.g. in my case I have following piece of html:

<div class="checkbox">
  <input
    id="terms-and-conditions"
    type="checkbox"
  >
  <label for="terms-and-conditions">
    I have read and accept
    <a class="terms-and-conditions-link" href="#" onclick="alert('Alert');">
      terms and conditions.
    </a>
  </label>
</div>

Clicking that link manually with Firefox or Chrome won't check that checkbox. When running tests with Testcafe & Chrome checkbox gets checked from clicking that link. Same won't happen with Testcafe & Firefox.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 27, 2019
@miherlosev miherlosev removed the STATE: Need response An issue that requires a response or attention from the team. label Aug 27, 2019
@LavrovArtem LavrovArtem removed their assignment Feb 26, 2020
@Artem-Babich Artem-Babich transferred this issue from DevExpress/testcafe-hammerhead Mar 29, 2022
@Artem-Babich Artem-Babich self-assigned this Mar 29, 2022
Artem-Babich added a commit to Artem-Babich/testcafe that referenced this issue Mar 29, 2022
Artem-Babich added a commit to Artem-Babich/testcafe that referenced this issue Mar 29, 2022
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 30, 2022
Artem-Babich added a commit to Artem-Babich/testcafe that referenced this issue Mar 30, 2022
Artem-Babich added a commit to Artem-Babich/testcafe that referenced this issue Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AREA: client FREQUENCY: level 2 SYSTEM: action simulation TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

6 participants