How to regain focus control after keytable blurable:false

How to regain focus control after keytable blurable:false

mustafamondmustafamond Posts: 40Questions: 11Answers: 0

I have a form which pops up a bootstrap modal containing a datatable with keytable so that cells can be selected visually with arrow keys or mouse click. The requirement of how to select an item to return to the calling form is to press a "Done" button next to the table which extracts the data from the cell that has focus, closes the modal, and inserts the data value into the appropriate form field. My initial problem was that when the "Done" button was clicked, the table cell that was selected lost focus returning "undefined" when trying to get the value of the focused cell. I found the blurable:false option which keeps focus on the table so that the button can extract the data now. This all works.

However, once the modal with the datatable is closed and I am back in the main form, I found I was unable to tab to the next field. Reading about the blurable option:

his ability to loose focus (blurring) can be disabled in KeyTable by setting this option to false. That means that once the table has been focused (which it can be automatically using keys.focus) focus cannot be removed (although interaction can be disabled using keys.disable()).

So, once I close the modal, I also do this:
table.keys.disable();
This does not seem to have any effect. Reading the description if the disable() function:

Disable KeyTable. Please note that this disallows future interactions with the table (until re-enabled), but does not cause the table to blur (i.e. loose focus). If a cell has focus, that focus will be retained after this method has been called.

So, despite what it says on the blurable page, if I understand correctly, the keys.disable() function does not remove the focus hold on the table.

Question: How do I restore the ability to give other elements in the page focus once I close the modal that contained the table (I do not need it at all anymore and if opened again, it can be re-initialized).

This discussion has been closed.