swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.62k stars 1.68k forks source link

'activate' event reports incorrect row/value #823

Open mikekov opened 7 years ago

mikekov commented 7 years ago

I'm submitting a ... (check one with "x")

[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 Take a look at http://swimlane.github.io/ngx-datatable/#cell-selection. Open dev tools and move selection around with arrow keys. You'll see that 'value' field lags behind what's selected.

The bug is here:

  onActivate(model: Model, index: number): void {
    const { type, event, row } = model;
    const chkbox = this.selectionType === SelectionType.checkbox;
    const select = (!chkbox && (type === 'click' || type === 'dblclick')) || 
      (chkbox && type === 'checkbox');
    if(select) {
      this.selectRow(event, index, row);
    } else if(type === 'keydown') {
      if ((<KeyboardEvent>event).keyCode === Keys.return) {
        this.selectRow(event, index, row);
      } else {
        this.onKeyboardFocus(model);
      }
    }
    this.activate.emit(model);
  }

onKeyboardFocus will move current cell/row, and activate.emit(model) reports stale information.

Expected behavior 'activate' event should report active cell/row.

Reproduction of the problem It's here: http://swimlane.github.io/ngx-datatable/#cell-selection

brunork26 commented 6 years ago

Is there any workaround for this issue?

mkprajeen commented 5 years ago

Need a fix for this issue

rupraj-mitel commented 5 years ago

This is a serious issue needed to be fixed on priority.

khadervali commented 5 years ago

If we have a fix for this issue, will helps a lot please consider as a priority issue.

richa0312 commented 1 year ago

we need this issue to be fixed as its important for us. Please let us know anyone is working on this? @mikekov do you have any other solution to fix this issue?