testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Disabled button with span inside triggers click event

Open Bamyan opened this issue 8 years ago • 6 comments

Are you requesting a feature or reporting a bug?

Bug.

What is the current behavior?

When you have disabled native button with span element inside, the click event is triggered in IE and Edge browsers.

What is the expected behavior?

Click event should not be triggered when a button is disabled.

How would you reproduce the current behavior (if this is a bug)?

  1. Create a disabled button with span element inside. Bind to the click event.
  2. Try to click it in IE/Edge browser.

Provide the test code and the tested page URL (if applicable)

<button disabled onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>

Specify your

  • operating system: Win7 - IE, Win10 - Edge
  • testcafe version: 0.20.1
  • node.js version: 8.9.4

Bamyan avatar Sep 26 '18 14:09 Bamyan

I was able to reproduce the issue in Edge

AlexKamaev avatar Sep 27 '18 08:09 AlexKamaev

fixed in https://github.com/DevExpress/testcafe-hammerhead/issues/1880

AlexKamaev avatar Dec 21 '18 08:12 AlexKamaev

@AlexKamaev I am not sure if this fix is correct. Let me show you the example:

In the very simple case your fix is correct. No console log is called when the button is clicked (and it behaves the same in TestCafe):

<!-- Won't log anything -->
<div onclick="console.log('div')">
	<button disabled onclick="console.log('button')">
    	   Click me
  	</button>
</div>

On the other hand, when the disabled button contains any other element, the click events are called (but not in TestCafe!):

<!-- Logs "span" "div" -->
<div onclick="console.log('div')">
	<button  onclick="console.log('button')">
    	<span onclick="console.log('span')">Click me</span>
  	</button>
</div>

palpatine1991 avatar Feb 15 '19 15:02 palpatine1991

@palpatine1991 Thanks for the information. I see the inconsistency in this behavior. I'll reopen the issue.

AlexKamaev avatar Feb 18 '19 08:02 AlexKamaev

I'll mark this issue as a duplicate since we have similar issue in the testcafe-hammerhead repository: DevExpress/testcafe#6949.  

AlexKamaev avatar Apr 16 '19 13:04 AlexKamaev

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

lock[bot] avatar Apr 26 '19 13:04 lock[bot]