Skip to content

Commit c75a2f9

Browse files
committed
fix(pages): fix goBackward and goForward checks
1 parent dde3ebd commit c75a2f9

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

apps/client/src/code/pages/pages.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,27 @@ export class Pages {
232232
}
233233

234234
async goBackward() {
235-
await this.goToPage(
236-
this.react.pathPageIds[
237-
this.react.pathPageIds.indexOf(this.react.pageId!) - 1
238-
],
239-
);
235+
const pageIndex = this.react.pathPageIds.indexOf(this.react.pageId!);
236+
237+
if (pageIndex > 0) {
238+
await this.goToPage(
239+
this.react.pathPageIds[
240+
this.react.pathPageIds.indexOf(this.react.pageId!) - 1
241+
],
242+
);
243+
}
240244
}
241245

242246
async goForward() {
243-
await this.goToPage(
244-
this.react.pathPageIds[
245-
this.react.pathPageIds.indexOf(this.react.pageId!) + 1
246-
],
247-
);
247+
const pageIndex = this.react.pathPageIds.indexOf(this.react.pageId!);
248+
249+
if (pageIndex < this.react.pathPageIds.length - 1) {
250+
await this.goToPage(
251+
this.react.pathPageIds[
252+
this.react.pathPageIds.indexOf(this.react.pageId!) + 1
253+
],
254+
);
255+
}
248256
}
249257

250258
destroy() {

0 commit comments

Comments
 (0)