You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bad news came when I realized that click('.foo') was triggering the foo action twice, first with a jquery.event with type click and a second time shortly after with a native MouseEvent.
Digging into the helper first and the addon later I've discover that the cause is that jquery's trigger triggers a jquery.event first, and if preventDefault is not called on that event, it fires a native event just afterwards, leading to unexpected behaviour (in my case, toggling a property twice and therefore letting it unchanged).
In real life the same code works perfectly because native events are fired instead.
I don't know if kebab actions, that will also receive native events, can be affected by this too.
Solutions I see:
A) Fire real events instead. Would it be backwards incompatible? I guess that the dispatcher would catch them and turn them into jquery events as it does with regular events in real life, and also mimics real behaviour better.
B) Accept a second argument in helpers click('.css-selector', { native: true }). Clearly backwards compatible, but leaves us with 2 different paths for firing events.
Thoughts?
The text was updated successfully, but these errors were encountered:
I was writing an acceptance test for something that looks like this:
Bad news came when I realized that
click('.foo')
was triggering thefoo
action twice, first with ajquery.event
with typeclick
and a second time shortly after with a nativeMouseEvent
.Digging into the helper first and the addon later I've discover that the cause is that jquery's
trigger
triggers a jquery.event first, and ifpreventDefault
is not called on that event, it fires a native event just afterwards, leading to unexpected behaviour (in my case, toggling a property twice and therefore letting it unchanged).In real life the same code works perfectly because native events are fired instead.
I don't know if kebab actions, that will also receive native events, can be affected by this too.
Solutions I see:
A) Fire real events instead. Would it be backwards incompatible? I guess that the dispatcher would catch them and turn them into jquery events as it does with regular events in real life, and also mimics real behaviour better.
B) Accept a second argument in helpers
click('.css-selector', { native: true })
. Clearly backwards compatible, but leaves us with 2 different paths for firing events.Thoughts?
The text was updated successfully, but these errors were encountered: