Black Lives Matter. Please consider donating to Black Girls Code today.

Autofocus to last DataTable on page load

I have an app with multiple data tables. Whenever I reload the page, it automatically scrolls down to the last data table and selects the first cell of that table. If I cut it down to just one data table, it still scrolls down to the first line of that table and selects the first cell.

I tried setting autofocus=True on a dcc.Input element to see if I could override the behavior, but no luck.

I’m using a hidden div to share data between callbacks. I tried moving that hidden div from the bottom of the page to the top of the page, but no luck there. I also tested commenting out the hidden div and all callbacks relating to it, but no luck there either.

The behavior happens on multi-page and single-page apps.

It really gets surprisingly irritating after awhile!