inovua / reactdatagrid

Empower Your Data with the best React Data Grid there is
https://reactdatagrid.io
Other
3.44k stars 55 forks source link

Datagrid has trouble maintaining orderly focus when cells render focusable elements #265

Closed yurigenin closed 1 year ago

yurigenin commented 2 years ago

Relevant code or config

import React from 'react'
import ReactDataGrid from '@inovua/reactdatagrid-enterprise'
import '@inovua/reactdatagrid-enterprise/index.css'

import flags from './flags'

const gridStyle = { maxHeight: 207 }

const columns = [
  { name: 'firstName', header: 'First Name', defaultFlex: 1 },
  {
    id: 'fullName',
    header: 'Full Name',
    minWidth: 100,
    defaultFlex: 1,
    render: ({ data }) => {   
      return <input value={data.firstName + ' ' + data.lastName}  />;
    }
  },
]

const dataSource = [
  { firstName: 'John', lastName: 'Grayner', country: 'usa', age: 35, id: 0 },
  { firstName: 'Mary', lastName: 'Stones', country: 'ca', age: 25, id: 1 },
  { firstName: 'Robert', lastName: 'Fil', country: 'uk', age: 27, id: 2 },
  { firstName: 'Mark', lastName: 'Twain', country: 'usa', age: 74, id: 3 },
  { firstName: 'Eric', lastName: 'White', country: 'usa', age: 74, id: 4 },
  { firstName: 'Elaine', lastName: 'Black', country: 'usa', age: 74, id: 5 },
  { firstName: 'Martha', lastName: 'Brown', country: 'usa', age: 74, id: 6 },
  { firstName: 'Blake', lastName: 'Red', country: 'usa', age: 74, id: 7 }
]

export default () => <ReactDataGrid
  idProperty="id"
  columns={columns}
  dataSource={dataSource}
  style={gridStyle}
/>

What happened:

When cells in the grid render focusable elements and not all rows are visible tabbing through focusable elements breaks down as grid scrolls down to reveal invisible rows.

To reproduce:

  1. Use the example above.
  2. Click on the first cell of the first row.
  3. Start 'Tab'-ing through focusable elements - focus will start going through input elements
  4. But after the 5th row the focus will never reach the 6th row's input element

This is just one of the patterns I noticed. There are others where focus jumps to random rows instead of following the order of input element in the grid.

inovua-admin commented 1 year ago

Fixed in version 5.3.0.