bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
38.09k stars 1.29k forks source link

Ability to disable browser history pushing on hx-boost? #617

Open edgar-tamm-uptime opened 3 years ago

edgar-tamm-uptime commented 3 years ago

Hello,

Was going to use this library to add some "progressive enhancement" or SPA like features, but hit upon a snag.

It didn't look like it is possible to disable history pushing when using hx-boost . E.g. tried something like this <div hx-boost="true" hx-push-url="false">..</div>, but it didn't disable the history.

The use case for it is the following. I have a main/root page which has sub sections which will be lazily loaded. These sub sections mostly will have the same basic CRUD actions: A data table, with links to create a new item or edit an existing one. The idea is that all of these links (& forms within them using the PRG (post-redirect-get) pattern) will replace the contents of the sub section in the root page (without the user leaving the root page).

Having the history changed works in a fairly basic use case: when using the browser back button. When user would refresh the page they would only see the underlying sub section page, which will be confusing to users (basically, as if the sub section would have been just a link, but because user is used to everything happening on the root page they would be confused & probably not able to proceed. I would like to avoid every sub section page having the same root/parent section). The bigger problem is when using the browsers forward button. The browser won't have any idea that the "forward" action should happen on the sub section. So you can click as many times as you want, but the page (/sub section) won't change.

So because everything should happen "inline" on the root page it would be beneficial to be able to disable history on hx-boost.

I guess I could not use hx-boost, but I wanted to do "progressive enhancement" or at least use the standard html a href / form action attributes and not have to use only hx-* attributes or define everything double (It didn't seem like I could just add hx-select/target for htmx to attach to the link). Maybe because the experience would be so different to users this wouldn't really be something to strive towards.

The other issue I haven't yet thought about would be sub section page specific javascript code that should be included (ie sub section would have a Githubissues.

  • Githubissues is a development platform for aggregating issues.