Primeng: Table erratic row selection with virtual scroll

Created on 16 Jun 2020  路  13Comments  路  Source: primefaces/primeng

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

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
With virtual scroll and selectionMode=single enabled, selecting a row and then scrolling in the lists makes the highlight jump around and rows that are not selected show as highlighted.

Expected behavior
Only actually selected row should have ui-state-highlight

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/primeng-table-virtual-scroll-selection
Select a row, then scroll.

LTS-FIXED-9.1.5 defect

Most helpful comment

I'm having the same problem with selectionMode=multiple and using checkboxes for selection. Unfortunately the fix from @szyzu does not work for me. Would be great to have this fixed.

All 13 comments

Is there a quick fix for this? Because it is really annoying...

Are there any news about this bug?

I'm facing the same issue: are there any news??

I've got the same problem, can you give us a workaround or a fix?

I had this problem too. This is my workaround:
Nagrywaj-2020-07-30-20-24-42-285

Disabled ivy:
https://stackblitz.com/edit/primeng-table-virtual-scroll-workaround-disabled-ivy

Enabled ivy(does not work on stackblitz):
https://stackblitz.com/edit/primeng-table-virtual-scroll-workaround

Would be great to have this resolved without an extra workaround. Although szyzus solution helps for the moment

I'm having the same problem with selectionMode=multiple and using checkboxes for selection. Unfortunately the fix from @szyzu does not work for me. Would be great to have this fixed.

Just ran into the same issue. A fix would be appreciated.

It would be nice to have it been fixed without the use of a workaround.
Any news about a fix?

I'm having the same problem with selectionMode=multiple and using checkboxes for selection. Unfortunately the fix from @szyzu does not work for me. Would be great to have this fixed.

i used that workaround for selectionMode=multiple and it's working but i had to debug to find that index in ngContext:

const dataKeyValue = ngContext[24][this.dataKey];

private updateRowHighlight(){
    const elements = document.getElementsByClassName('ui-selectable-row');
    for (let i = 0 ; i < elements.length; i++){
      const ngContext = elements[i]['__ngContext__'];
      const dataKeyValue = ngContext[24][this.dataKey];
        if( this.entitySelected.findIndex(a=>a[this.dataKey]==dataKeyValue)==-1){
          elements[i].classList.remove('ui-state-highlight');
        }
        else{
          elements[i].classList.add('ui-state-highlight');
        }
    }
  }

I'm having the same problem with selectionMode=multiple and using checkboxes for selection. Unfortunately the fix from @szyzu does not work for me. Would be great to have this fixed.

i used that workaround for selectionMode=multiple and it's working but i had to debug to find that index in ngContext:

const dataKeyValue = ngContext[24][this.dataKey];

private updateRowHighlight(){
    const elements = document.getElementsByClassName('ui-selectable-row');
    for (let i = 0 ; i < elements.length; i++){
      const ngContext = elements[i]['__ngContext__'];
      const dataKeyValue = ngContext[24][this.dataKey];
        if( this.entitySelected.findIndex(a=>a[this.dataKey]==dataKeyValue)==-1){
          elements[i].classList.remove('ui-state-highlight');
        }
        else{
          elements[i].classList.add('ui-state-highlight');
        }
    }
  }

We need a solution to this asap, hope that developers will catch us up with some news about it

I'm having the same problem with selectionMode=multiple and using checkboxes for selection. Unfortunately the fix from @szyzu does not work for me. Would be great to have this fixed.

Is team is this issue fixed or not?

I'm having the same problem with selectionMode=multiple and using checkboxes for selection. Unfortunately the fix from @szyzu does not work for me. Would be great to have this fixed.

Is team is this issue fixed or not?

yes, it has been resolved and is in the LTS 9.1.5 version. In version 10 already has this correction as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Helayxa picture Helayxa  路  3Comments

pchristou picture pchristou  路  3Comments

philly-vanilly picture philly-vanilly  路  3Comments

cyberrranger picture cyberrranger  路  3Comments

garethlewis picture garethlewis  路  3Comments