Skip to content

Commit

Permalink
Improved piral-ng URL dispatching
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Aug 25, 2023
1 parent 788b1f1 commit 486ba13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.2.0 (tbd)

- Fixed issue with `loader-utils` version
- Fixed issue with potential URL flickering using `piral-ng`
- Fixed build issue in codegen of `piral-core` on Windows (#619)
- Updated `importmap` with `exclude` key allowing exclusions
- Added support for `dependencySymbols` in `piral-blazor`
Expand Down
8 changes: 6 additions & 2 deletions src/converters/piral-ng/src/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export class RoutingService implements OnDestroy {
const skipIds: Array<number> = [];
const nav = this.context.navigation;

const queueNavigation = (url: string) => {
window.requestAnimationFrame(() => nav.push(url));
};

this.dispose = nav.listen(({ location }) => {
const path = location.pathname;

Expand All @@ -84,7 +88,7 @@ export class RoutingService implements OnDestroy {
}

if (routerUrl !== locationUrl) {
nav.push(routerUrl);
queueNavigation(routerUrl);
}
} else if (e.type === 0 && skipNavigation) {
skipIds.push(e.id);
Expand All @@ -97,7 +101,7 @@ export class RoutingService implements OnDestroy {
const routerUrl = e.routerEvent.url;

if (routerUrl !== locationUrl) {
nav.push(routerUrl);
queueNavigation(routerUrl);
}
} else {
skipIds.splice(index, 1);
Expand Down

0 comments on commit 486ba13

Please sign in to comment.