dash icon indicating copy to clipboard operation
dash copied to clipboard

add new persistence_type: history_state

Open olejorgenb opened this issue 1 year ago • 0 comments

When basing the app around internal links which add entries to the browser history it could be useful with a persistence type which stores the values in the history state entries (history.pushState(state, ...)).

I know that ideally most/all such state would be part of the URL as this has more advantages beyond preserving the state on back/forward. But sometimes this can be a bit tricky - using URL parameters for state does require a certain app architecture - so I think it could be useful to easily add some state to the history entry "under the hood".

I think this could be reasonable easy to implement. Do a replaceState({...history.state, ...historyProps}, ...) each time a "history-state persisted" property is changed. Then restore these in a "popstate" event handler.

(I could not find any previous discussion on this topic)

olejorgenb avatar Sep 03 '24 18:09 olejorgenb