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

Replace the tab entries on first load #3041

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/zui/src/models/browser-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ export class BrowserTab extends DomainModel<Attrs> {
if (this.history.location.pathname === pathname) {
this.history.replace(pathname)
} else {
// Whenever a tab is created it constructs itself with a root entry "/".
// This can mess up the tab history back button, allowing the user to
// get back to this "root" url which does not contain forward/back buttons.
// Instead, this if statement resets the entries and index for this tab
// if the only url in the entries array is "/", making it the
// first entry in the history the first pathname given to browerTab.load()
if (this.history.length == 1 && this.history.location.pathname === "/") {
this.history.entries = []
this.history.index = -1
}
this.history.push(pathname)
console.log(this.history)
}
}

Expand Down
5 changes: 5 additions & 0 deletions packages/zui-player/tests/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ test.describe('Query tests', () => {
await app.shutdown();
});

test('session initializes with the back button disabled', async () => {
const backButton = app.locate('button', 'Go Back');
await expect(backButton).toBeDisabled();
});

test('session queries are the default and ordered properly in history', async () => {
await app.query('1');
await app.query('2');
Expand Down
Loading