Using the following ReactGrid component, is it possible to programmatically set focus to a specific cell?
import { ReactGrid } from '@silevis/reactgrid';
Can anyone point me to documentation or provide any insight on if this is possible or not? I have tried using javascript to set the focus, for example:
`const cellElement = gridRef.current.querySelector(`[data-cell-colidx="${columnIdx + 1}"][data-cell-rowidx="${rowIdx}"]`);
if (cellElement) {
cellElement.setAttribute('tabindex', '-1');
cellElement.addEventListener('focus', () => console.log('Cell focused'));
cellElement.focus();
}`
and I get a console log that cell is focused, but the border highlight doesn’t move to the cell I am trying to focus, and also when I start typing it still enters text into the original cell.
I appreciate any guidance and everyone who took the time to read this.
I tried the code that I entered in the details of the problem above, and I was expecting for the focus to shift to the new cell and to be able to begin typing into it.
Aaron N is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.