Skip to content

Commit a2e178d

Browse files
authored
Replace the tab entries on first load (#3041)
1 parent 308ed3c commit a2e178d

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

apps/zui/src/models/browser-tab.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@ export class BrowserTab extends DomainModel<Attrs> {
3838
if (this.history.location.pathname === pathname) {
3939
this.history.replace(pathname)
4040
} else {
41+
// Whenever a tab is created it constructs itself with a root entry "/".
42+
// This can mess up the tab history back button, allowing the user to
43+
// get back to this "root" url which does not contain forward/back buttons.
44+
// Instead, this if statement resets the entries and index for this tab
45+
// if the only url in the entries array is "/", making it the
46+
// first entry in the history the first pathname given to browerTab.load()
47+
if (this.history.length == 1 && this.history.location.pathname === "/") {
48+
this.history.entries = []
49+
this.history.index = -1
50+
}
4151
this.history.push(pathname)
52+
console.log(this.history)
4253
}
4354
}
4455

packages/zui-player/tests/queries.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ test.describe('Query tests', () => {
1515
await app.shutdown();
1616
});
1717

18+
test('session initializes with the back button disabled', async () => {
19+
const backButton = app.locate('button', 'Go Back');
20+
await expect(backButton).toBeDisabled();
21+
});
22+
1823
test('session queries are the default and ordered properly in history', async () => {
1924
await app.query('1');
2025
await app.query('2');

0 commit comments

Comments
 (0)