Skip to content

Conversation

@jameskerr
Copy link
Contributor

@jameskerr jameskerr commented Apr 2, 2024

Context
When a tab history object is created, it already contains a single entry with the root pathname "/". In a previous PR, I changed the order of creating session tabs to 1) create the tab, 2) load the url in that tab. This made the code much easier to reason about, but it left this dangling "/" entry in the tab history. The meant the back button was enabled on a newly created session tab. If clicked, the tab would go back to the "/" url which renders a blank page without any buttons. You could not get back to your session if you ended up in this state. Could be very irritating if you needed those session history queries.

Changes
So this PR changes the BrowserTab#load function. It checks if the tab history entries equals ["/"]. If it does, it resets the entries to [] and the index to -1, the pushes the new pathname onto the history. This is exactly what we want. The "action" on the entry is still "push" instead of "replace" so that all the normal things happen.

Tests
There is an e2e test added that checks the back button on a newly created session tab to ensure it is disabled, meaning there is only one item in the tab history entries.

@jameskerr jameskerr merged commit a2e178d into main Apr 2, 2024
@jameskerr jameskerr deleted the tab-navigation branch April 2, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants