How can I keep range selection active even if user clicks inside the grid

Tags: #<Tag:0x00007f51b4d4fd20> #<Tag:0x00007f51b4d4fbe0>

Hello team,

I have a requirement where the grid is read-only, and based on user inputs like start-end row and column we programmatically highlights the particular range using selectCells.

We are using outsideClickDeselects: false to keep the selection active. But when user clicks on any cell/header inside grid the selection goes away.

It would be helpful if I get some pointers to keep the selection active until other range gets selected using selectCells.

I am using below handsontable config –

selectionMode: 'multiple'
disableVisualSelection: 'current'
outsideClickDeselects: false

I believe the solution lies within the hooks but not sure which ones to use. :expressionless:

Thanks in advance!

Hi @manjushamule7

That’s correct. Clicking anywhere inside the table will bypass the outsideClickDeselects option as our internal focus manager requires to have an information about the selected position if it happens inside the table. That’s why we don’t have any hooks that would control that behavior.

The only way to make it work would be to use the hook afterOnCellMouseDown and implement a custom logic that will force to not register selection, but that might result in unexpected errors.

1 Like

Thank you @adrian.szymanski

It worked!! We can close the query.