Selection broken in data table in a view with several rows

Hello,

I have encountered a bug in webix that I can only reproduce in electron environment:

Put a toolbar (or any view) and a data table in rows. Datatable must have a small number of rows so it does not fill all vertical space.
With your mouse, scroll the data table and then click on any row to select it
webix throws the following error:

Uncaught TypeError: Cannot read property 'id' of undefined
    at h.nl (webix_debug.js:22077)
    at h.kl (webix_debug.js:22153)
    at hl (webix_debug.js:22013)
    at h.bl (webix_debug.js:22102)
    at h.<anonymous> (webix_debug.js:248)
    at h.iA (webix_debug.js:21329)
    at h.Yc (webix_debug.js:21384)
    at h.Sc (webix_debug.js:6743)
    at HTMLDivElement.<anonymous> (webix_debug.js:248)

To reproduce:

Create a new folder, let’s call it scroll
Cd to scroll
run npm init and choose defaults
run npm install --save-dev electron
run npm install webix
edit file package.json and add “start”: “electron .” to “scripts”
create a file index.js and add the following content:

const app = require('electron').app;
const BrowserWindow = require('electron').BrowserWindow;

let win;
function createWindow () {
  win = new BrowserWindow({ width: 800, height: 600 })
  win.loadFile('index.html')
  win.on('closed', () => {
    win = null
  })
}
  
app.on('ready', createWindow)
  
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})
  
app.on('activate', () => {
  if (win === null) {
    createWindow()
  }
})

Create file index.html with the following content:

<!DOCTYPE html>
  <html>
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="./node_modules/webix/webix.css" type="text/css" charset="utf-8">
      <title>Scroll</title>
    </head>
    <body>
      <div id="settings-container" style="width: 800px;"></div>
      
      <script src="./node_modules/webix/webix.js" type="text/javascript" charset="utf-8"></script>
      <script src="./app.js" type="text/javascript" charset="utf-8"></script>
    </body>
  </html>
and finally create a file app.js with the following content:
const grid_data = [
	{ id:1, title:"The Shawshank Redemption", year:1994, votes:678790, rating:9.2, rank:1},
	{ id:2, title:"The Godfather", year:1972, votes:511495, rating:9.2, rank:2},
	{ id:3, title:"The Godfather: Part II", year:1974, votes:319352, rating:9.0, rank:3},
	{ id:4, title:"The Good, the Bad and the Ugly", year:1966, votes:213030, rating:8.9, rank:4},
	{ id:5, title:"My Fair Lady", year:1964, votes:533848, rating:8.9, rank:5},
	{ id:6, title:"12 Angry Men", year:1957, votes:164558, rating:8.9, rank:6}
];
webix.ui({
  rows: [
    {
      id: 'panel-1',
      type: "clean",
      rows: [
        { template: "Pnael",
        },
        {
          view: "datatable",
          id: 'tbl-1',
          select: "row",
          multiselect: true,
          scrollX: true,
          columns:[
            { id:"rank",	header:"", css:"rank",  		width:50},
            { id:"title",	header:"Film title",width:200},
            { id:"year",	header:"Released" , width:80},
            { id:"votes",	header:"Votes", 	width:100}
          ],
          data:grid_data,
        },
      ],
    },
  ],
});

Now run the application using npm startfrom the command line and use the steps described at the beginning te reproduce the bug.

Unfortunately, I couldn’t reproduce the problem, as your project is running smoothly in my environment.

Hello,

We would be grateful if you could provide a link to a live demo with “webix_debug.js” included, or succeed in repeating it in the isolated environment, or provide a human-readable error stack (should be in the console, if debug version is used).

Hello,

Thank you for your feedback.
I can only reproduce this in electron environment. I have published a repository in github to reproduce the bug using webix_debug.js: GitHub - bouagja/scroll: Sample Electron App to reproduce a bug in datatable
Just clone the repository using

git clone https://github.com/bouagja/scroll
cd scroll
npm install
npm start

When the application window is open, just scroll the datatable and try to select any row. You will see that the selection is off by 1 and if you try to select the first row you will get the following error in the console:

Uncaught TypeError: Cannot read property 'id' of undefined
    at result._add_item_select (webix_debug.js:22077)
    at result._post_select (webix_debug.js:22153)
    at result._select (webix_debug.js:22013)
    at result._click_before_select (webix_debug.js:22102)
    at result.<anonymous> (webix_debug.js:248)
    at result._mouseEventCall (webix_debug.js:21329)
    at result._mouseEvent (webix_debug.js:21384)
    at result._onClick (webix_debug.js:6743)
    at HTMLDivElement.<anonymous> (webix_debug.js:248)