Re:Show HN: Simple tool to generate mock APIs for testing
by giancarlostoro on Saturday February 17, 2024 @08:13AM
(#39409131)
Maybe only generate a new url when they ctrl + s or hit a save button? This would be more like what you want? I think CodePen does this idr. Or keep a revision list in localstorage with all urls that would have been generated.
Re:Show HN: Simple tool to generate mock APIs for testing
by fadymak on Saturday February 17, 2024 @08:15AM
(#39409145)
I think local storage and keyboard shortcuts might be a good alternative - thanks for the suggestion :)
Re:Show HN: Simple tool to generate mock APIs for testing
by orphea on Saturday February 17, 2024 @06:48AM
(#39408611)
jotaen explained it well. Sorry if I sounded mean, at some point you start to get tired of the websites that break the basic behavior of the browser.
Do not use history.pushState to update the URL if whatever is happening on the page doesn't count as navigation. Try to look into history.replaceState and see if it helps.
Re:Show HN: Simple tool to generate mock APIs for testing
by jotaen on Saturday February 17, 2024 @06:56AM
(#39408658)
I’d tend to agree that using the browser history doesn’t feel like the right solution for this kind of undo/redo functionality. In my mind, undo/redo actions are too fine-granular, and pollute the history, which can be very inconvenient.
Another potential approach could be to offer a custom-built widget for the undo/redo stack in the UI – in the simplest case, for example, a dropdown. It could also be persisted somewhere, e.g. in local storage, so that it isn’t lost when you navigate away.
Re:Show HN: Simple tool to generate mock APIs for testing
by fadymak on Saturday February 17, 2024 @07:00AM
(#39408685)
Thanks for all the feedback! This community is incredible <3
Just pushed a fix that should resolve this while still maintaining state in the URL (using replaceState as suggested by OP).
For now it foregoes the undo/redo. I'll explore implementing it as a separate widget as you suggest in the future.
Initially this was a design decision to make it easy to share the URL of the Mock API you built with other developers. However, I can see this is breaking user expectations - I’ll work on getting that changed so it’s more in line with what users expect.
I appreciate the feedback because initially that felt “natural” to me but I can see how it might not be intuitive to others.