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

Clicking on disabled input checkbox modify checked value #120

Open
livet01 opened this issue Nov 24, 2017 · 11 comments
Open

Clicking on disabled input checkbox modify checked value #120

livet01 opened this issue Nov 24, 2017 · 11 comments
Labels

Comments

@livet01
Copy link

livet01 commented Nov 24, 2017

I create a component my-input-component.hbs:

<input type="checkbox"
   checked={{checked}}
   disabled={{disabled}}>

and I add a integration test:

import { click, find } from 'ember-native-dom-helpers';
//...
test('disabled state', async function(assert) {
   await render(hbs`{{my-input-component disabled=true checked=false}}`);
   assert.notOk(find('input[type="checkbox"]').checked);

   await click('input[type="checkbox"]');
   assert.notOk(find('input[type="checkbox"]').checked);
});

The second assert.notOk fails, find('input[type="checkbox"]').checked returns true.

If I replace click helper by something like that, it's working:

Ember.run(() => document.querySelector('input[type="checkbox"]').click());

Do you have any idea about why click has this behaviour? Thanks.

@cibernox
Copy link
Owner

Not really, it should behave the same. Is the checkbox properly disabled?

@livet01
Copy link
Author

livet01 commented Nov 27, 2017

Yes, the checkbox remain disabled.

@livet01
Copy link
Author

livet01 commented Nov 27, 2017

When I try to build my own click event:

var event = document.createEvent('MouseEvents');
event.initMouseEvent('click');
var element = document.querySelector('input[type="checkbox"]');
console.log(element.checked, element.disabled); // false true

element.dispatch(event);
console.log(element.checked, element.disabled); // true true

I can reproduce the behaviour. click event doesn't seem to keep the native behaviour of the checkbox. 🤔

@cibernox
Copy link
Owner

That is interesting. I don't know why firing a mouse event on a disabled checkbox is different that calling .click() on it, but I do think it's something that should be fixed.

@cibernox
Copy link
Owner

Can you only verify that this is not a browser bug by testing it on firefox and safari or edge? If so, this must deserve some special case.

@cibernox cibernox added the bug label Nov 27, 2017
@livet01
Copy link
Author

livet01 commented Nov 27, 2017

Interesting, on firefox I can't reproduce the bug and my tests are green.

@cibernox
Copy link
Owner

More or less what I was expecting. This totally looks like a browser bug to me. What about safari and edge?

@livet01
Copy link
Author

livet01 commented Nov 27, 2017

Bug is here on Safari (so webkit) and not here on Edge.

@cibernox
Copy link
Owner

So we have a Chrome/Safari VS firefox/edge discrepancy in hands. I think we should report it. I think that the firefox/edge behaviour is the correct one.

@livet01
Copy link
Author

livet01 commented Nov 27, 2017

I'll see to report that to Webkit.

But, do you think it worth to fix it on this repo?

@cibernox
Copy link
Owner

I think I wouldn't oppose if the fix is reasonably simple and we leave a comment linking to the bug-report, so we can remove the hack once it's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants