I'm submitting a ...
[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
```
Current behavior
Activate event is firing on mouseenter, i.e. when hovering over a row.
Expected behavior
Activate event should only fire on click
Reproduction of the problem
A ngx-datatable with (activate)="onActivate($event)"
What is the motivation / use case for changing the behavior?
Trying to subscribe to the click event of a row.
Activate is now firing when the user hovers on a row.
This was not the behavior in prior versions (<10)
Please tell us about your environment:
Table version: 10.2
Angular version: 4.4
Browser: Chrome
Language: All
This a new feature I requested (also listed in changelog), and you can easily filter events
I was confused at first. I fixed with this.
onActivate(event) {
if (event.type === 'click') {
// Code
}
}
what if i remove the onActivate from code, does this will produce any problem, i'm not getting that what's the use of (activate)="onActivate($event)"
my code is <ngx-datatable
class="material"
[rows]="rows"
[columnMode]="'force'"
[columns]="columns"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="'auto'"
[limit]="5"
[selected]="selected"
[selectionType]="'multiClick'"
(select)='onSelect($event)'>
</ngx-datatable>
In this, i have removed the (activate) property, will this cause any problem because as per now, it is not giving any error and table is working fine....
IF ANYBODY SEEING THIS--- PLEASE EXPLAIN THE SIGNIFICANCE OF (activate)="onActivate($event)"
Essentially activate is all mouse events if you don't need it. don't use it.
find out more and log it
I'm not surprised this gets reported as a bug by the community.
The documentation still says about activate: A cell or row was focused via keyboard or mouse click.
The types also only state: type: 'keydown'|'click'|'dblclick'
This change does not "backwards-compatible" very well, and is a rather surprising breaking change.
I can image a lot of users are not checking the type, because the previous event types are all very similar, and rather than repeating the same action or iffing on 3 event types, you'd just trigger one action regardless.
Right now with this change though, a hover event is a pretty significantly different event type and it's a bit odd to introduce this on the same event emitter. I would rather have added a new event emitter (hover)=onHover($event) or something?
Here is a link to the PR
Just a word of caution, this may break people who don't check the event type but depend somehow on the event to maintain some kind of state. An earlier project I worked on did just that.
Even though it was adding a feature, which you don't think of as a breaking change, people may be subscribing to the events and doing something specific for keyboard or mouse clicks and don't filter out the events. Too bad you can't enforce that the code checks the type before processing the event as to make it better future proof.
+1 on adding documentation, and also should say in the API usage, to check the type before using to prevent breaking in future non-major version releases.
Just ran across this -- would be great if it was reflected in the documentation.
mouseenter event is also causing performance overhead, just put a breakpoint in a rowClass method it will be called on every mouseenter for every table row item. Like if there's no virtualisation, rowClass will be called 100 times for 100 items on a single mouseenter
hi all,
How can i disable this feature.
this is my code for activate handler
onActivate(event) {
console.log('onActivate');
if (event.type === 'mouseover') {
console.log('onActivate.mouseover');
event.preventDefault();
event.stopPropagation();
return;
}
}
and usage as <ngx-datatable #table (activate)="onActivate($event)"></ngx-datable>
But it still not work, i'm not sure about the above way for filter event.
Thanks.
Most helpful comment
hi all,
How can i disable this feature.
this is my code for activate handler
onActivate(event) { console.log('onActivate'); if (event.type === 'mouseover') { console.log('onActivate.mouseover'); event.preventDefault(); event.stopPropagation(); return; } }and usage as
<ngx-datatable #table (activate)="onActivate($event)"></ngx-datable>But it still not work, i'm not sure about the above way for filter event.
Thanks.