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

fix(b-router/modules/transition): fix promises collision #1367

Merged
merged 3 commits into from
Aug 1, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.118 (2024-08-01)

#### :bug: Bug Fix

* Added `join: 'replace'` for router transitions. It allows to avoid collisions during calls of `push` and `replace` `b-router`

## v4.0.0-beta.117 (2024-07-31)

#### :house: Internal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packageManager": "yarn@4.0.2",
"typings": "index.d.ts",
"license": "MIT",
"version": "4.0.0-beta.117",
"version": "4.0.0-beta.118",
"author": {
"name": "kobezzza",
"email": "kobezzza@gmail.com",
Expand Down
6 changes: 6 additions & 0 deletions src/components/base/b-router/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]

## v4.0.0-beta.118 (2024-08-01)

#### :bug: Bug Fix

* Added `join: 'replace'` for router transitions. It allows to avoid collisions during calls of `push` and `replace`

## v4.0.0-beta.112 (2024-07-22)

#### :bug: Bug Fix
Expand Down
13 changes: 8 additions & 5 deletions src/components/base/b-router/modules/transition/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import symbolGenerator from 'core/symbol';

import type { AsyncPromiseOptions } from 'core/async';

import * as router from 'core/router';
import type { Router } from 'core/router/interface';

Expand All @@ -20,8 +22,9 @@ import type { TransitionContext } from 'components/base/b-router/modules/transit
const
$$ = symbolGenerator();

const transitionLabel = {
label: $$.transition
const transitionOptions: AsyncPromiseOptions = {
label: $$.transition,
join: 'replace'
};

export default class Transition {
Expand Down Expand Up @@ -156,13 +159,13 @@ export default class Transition {
this.initNewRouteInfo();

this.scroll.createSnapshot();
await $a.promise(this.scroll.updateCurrentRouteScroll(), transitionLabel);
await $a.promise(this.scroll.updateCurrentRouteScroll(), transitionOptions);

// We didn't find any route matching the given ref
if (this.newRouteInfo == null) {
// The transition was user-generated, then we need to save the scroll
if (!SSR && this.method !== 'event' && this.ref != null) {
await $a.promise(engine[this.method](this.ref, this.scroll.getSnapshot()), transitionLabel);
await $a.promise(engine[this.method](this.ref, this.scroll.getSnapshot()), transitionOptions);
}

return;
Expand Down Expand Up @@ -268,7 +271,7 @@ export default class Transition {
return;
}

await $a.promise(engine[this.method](newRoute.url, plainInfo), transitionLabel).then(() => {
await $a.promise(engine[this.method](newRoute.url, plainInfo), transitionOptions).then(() => {
const isSoftTransition = r.route != null && Object.fastCompare(
router.convertRouteToPlainObjectWithoutProto(currentRoute),
router.convertRouteToPlainObjectWithoutProto(newRoute)
Expand Down
Loading