After hours of fruitless "debates" with three different LLMs, I'm hoping someone here has encountered the following bug in DT and found a workaround. The problem is that using a slider column filter (numeric or data column) in a table wider than the visible window triggers impromptu horizontal scrolling.
Click in the filter control of any column near the left and a slider pops up as expected. Now scroll to the far right and try setting a filter there. The table spontaneously scrolls back to the left.
After setting a filter in a right-hand column, the reverse occurs. Go back to the left and try to set a filter there. The table scrolls to the right.
I'm pretty sure I am not the first person to encounter this. Has anyone found a fix? Thanks.
I don't think there's a reliable R-side fix for this.
Since DT is essentially a wrapper around the underlying DataTables library, any workaround implemented purely in Shiny/DT (for example, manually capturing and restoring scrollLeft through custom JS callbacks) would be fairly fragile and could easily break with future DT or DataTables releases.
In other words, I'd treat this as a bug that really needs to be fixed at the JavaScript layer—or in the DT bridge code that integrates those widgets with R—rather than something that can be robustly solved from user code. Temporary hacks may exist, but I wouldn't expect them to be version-stable
Thanks for the suggestions! I have already tried putting the table in a container (div) with the container scrolling horizontally and the table not having a horizontal scrollbar. Various iterations of that failed with various pathologies (including, in at least one case, the data scrolling horizontally but the column headings not moving).
I just tested the suggestion to disable autoWidth and use fixed column widths. It took some serious voodoo to get fixed column widths, but ultimately the spontaneous scrolling problem remained.
I'm using Shiny 1.14.0 and DT 0.34.0, both of which should be most recent.
I found multiple issues regarding this in the DT GitHub repository ... and a suggested workaround that works pretty well for my program. That said, I do wish the developers would fix the bug.