Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing the name of a specimen pollutes the browser URL history #482

Open
gwhitney opened this issue Oct 30, 2024 · 4 comments
Open

Editing the name of a specimen pollutes the browser URL history #482

gwhitney opened this issue Oct 30, 2024 · 4 comments
Labels
question Further information is requested ui Something having to do with the user interface

Comments

@gwhitney
Copy link
Collaborator

To reproduce, go to the Gallery and select (say) the "Thue Trellis" specimen. Then click to the right of the name "Thue Trellis" in the specimen bar at the top. Then backspace seven times to erase "Trellis" and type "Fractal". Indeed, the name of the specimen is now "Thue Fractal". However, if you now right-click on the back button (or whatever you do in the browser of choice) to display the URL history of that browser window, you will see there are 14 URLs, identical except for the names "Thue Trelli", "Thue Trell", ..., "Thue Fracta", "Thue Fractal". This is excessive, and makes navigation to actual previous specimens cumbersome.

My recommendation is that a new URL should be pushed only when "input is complete" -- perhaps we can detect that by the input bar for the name losing focus? Anyone have suggestions on exactly how to do this?

@gwhitney gwhitney added question Further information is requested ui Something having to do with the user interface labels Oct 30, 2024
@gwhitney
Copy link
Collaborator Author

Another possibility would be to have the URL with the name changed simply replace the current page in the history. In other words, in the above scenario, the history would end up with just one entry, showing the name "Thue Fractal". There would be no record (in the browser history) that the name had previously been "Thue Trellis". So one additional important question is after a "completed" name edit (however we might detect that the edit has completed), do we want the browser history to have two entries, one with the original name and one with the new name (but otherwise not differing), or do we want just one entry, with the new name, and the original name "forgotten" from the perspective of the browser history?

In other words, in the first scenario, if you start at visualization A, load visualization B with name "Cool Viz", edit the name to "Nice Visualization" (and "complete" that edit, however that works), then the "back" button would go to Visualization B but with the name reverted to "Cool Viz" and then the "forward" button would go to B with name "Nice Visualization".

In the second scenario, if you did the exact same actions, the "back" button would go to Visualization A, and then forward would go to B with name "Nice Visualization". There would be no history entry mentioning "Cool Viz".

Which of these behaviors do we prefer (or something else)? Either is vastly better than the current dozens of entries in the visualizer when you do edits. I know exactly how to implement the "second scenario" (no "Cool Viz" ending up in the history); I am much less clear how to accomplish the scenario in which there is a single entry remembering the "Cool Viz" name, but I am sure we can manage it one way or another if we decide that's the behavior we want.

@katestange
Copy link
Member

I don't see any particular reason to dislike the second scenario. If nothing has changed but the name, I think it is reasonable to assume that the new name is preferred.

Is this an issue with edits to the sequence formula type letter-by-letter?

@gwhitney
Copy link
Collaborator Author

I don't see any particular reason to dislike the second scenario. If nothing has changed but the name, I think it is reasonable to assume that the new name is preferred.

OK, unless we hear counterpoint for @Vectornaut then whoever gets to this should just implement the second scenario by changing router.push() to router.replace() in the code that handles keystrokes in the name field of the specimen bar.

Is this an issue with edits to the sequence formula type letter-by-letter?

Excellent point. The problem is less severe, in that only correctly parsing formulae are saved to the browser history. So en route to n^3 + n^2 - 1, you will get history entries for n, n^3, n^3 + n, and n^3 + n^2. The difficulty is that I don't see how one could possibly distinguish "things you tried" from "things you were just typing through". So I am less inclined to fight that battle.

@katestange
Copy link
Member

Oh yeah, the sequence formula thing is really not that bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested ui Something having to do with the user interface
Projects
None yet
Development

No branches or pull requests

2 participants