Hey!
I have an index page which is filterable by typing into a search input. 500ms after the user stopped typing, the app fetches an updated records table from the server like this:
$.get(`${path}.js?${$.param(searchParams)}`)
Rails then responds with some js which replaces the table while the search input isn’t changed so the browser doesn’t lose focus on the field. I tried doing this with a regular Turbolinks.visit call, but the search field would lose focus with that, iirc. So in order to make the resulting page bookmarkable, I’m doing this:
Turbolinks.controller.pushHistoryWithLocationAndRestorationIdentifier(`${path}?${$.param(searchParams)}`, Turbolinks.uuid())
And that worked like a charm. Now with Turbo, I couldn’t find anything like this. I found How to use Turbo.visit() and target a specific frame? - #2 by javan and that works for replacing the results, but obviously the url wouldn’t change automagically.
So, is there any option I can manually change the url/push that new state in a Turbo-friendly way? I’m also open for alternatives to this manual hack, I just want live-updates on typing without losing focus on the field and url updates.
Thanks! Tobias