turbo_power icon indicating copy to clipboard operation
turbo_power copied to clipboard

[Feature Request] Add or improve history actions

Open pySilver opened this issue 3 years ago • 5 comments

Thanks for the great lib!

It would be nice to have a shortcut to modify Turbo.navigator.history. I find it an essential action since the Back button is not doing what is expected when the browser history is modified without touching Turbo.navigator.history. As a workaround, the invoke action can be used at the moment.

More on the issue: https://discuss.hotwired.dev/t/back-button-not-working/3012

P.S. I'd really love to help but I'm not very familiar with Typescript yet :/

pySilver avatar Nov 09 '22 13:11 pySilver

Thanks for opening this!

I'm happy to take a look on adding such an action!

marcoroth avatar Nov 09 '22 14:11 marcoroth

@marcoroth FYK navigation isn't that simple, unfortunately. See this: https://github.com/hotwired/turbo/issues/792

pySilver avatar Nov 15 '22 16:11 pySilver

I was wondering if expanding the push_state action would be worth thinking about: https://github.com/marcoroth/turbo_power/blob/623a6f5b11608073ac36880bd1f0cc4745a52e56/src/actions/history.ts#L3-L9

marcoroth avatar Nov 15 '22 18:11 marcoroth

Sounds OK if that would let one push state solely on window.history or the Turbo.navigator.history (sometime you want or another)

pySilver avatar Nov 15 '22 18:11 pySilver

Yeah, I thought it could be similar to how redirect_to works.

https://github.com/marcoroth/turbo_power/blob/623a6f5b11608073ac36880bd1f0cc4745a52e56/src/actions/browser.ts#L17-L29 By default it uses the one on Turbo, but if you don't want that or if Turbo is not available it falls back to window

marcoroth avatar Nov 15 '22 18:11 marcoroth