Skip to content

next(false) clears path on global Navigation Guards #3807

@daniil4udo

Description

@daniil4udo

@posva, sorry my bad in the example, but I found the reason behind my "path flashes", it's ensureURL method in the HTML5History class.

// next(false) -> abort navigation, ensure current URL
this.ensureURL(true)

If we take a look at this method

ensureURL (push?: boolean) {
  if (getLocation(this.base) !== this.current.fullPath) {
    const current = cleanPath(this.base + this.current.fullPath)
    push ? pushState(current) : replaceState(current)
  }
}

if I try to go straight to the restricted path, at some point, in my app I have next(false), that causes half-second absolutely clear URL.

When I logged vars in this method I noticed that it pushes to to url WITH aborting navigation.

image

When I commented that ensureURL(true) app worked as expected without annoying flashes.

Could you plz explain why do we need it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions