Dogstudio / highway

Highway - A Modern Javascript Transitions Manager

Home Page:https://highway.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Url parameters ignored

TristanPct opened this issue · comments

Hello,

Thanks for this cool plugin.

After some testing I find a case where Highway ignore my link: if I'm on a page and the link target the same page but with parameters.
For example, I'm on http://example.com/listing and I click to go to http://example.com/listing?page=2 and nothing happen.

After investigations, it seems to come from a Core#click method which doesn't test url parameters:

if (!this.navigating && pathname !== this.state.pathname) {

Hi @TristanPct,

You're right, thanks for your investigation !
It's really helpful since we couldn't cover all scenarios.

Indeed for now we are only checking for anchors in URL but not for parameters...
We will fix it as soon as possible and use the same technique as for the anchors...

This means we will probably hard-reload the page for parameters instead of using the transition.
It doesn't make sense to trigger a transition to come back on the same page, does it ?

Thanks again and we'll keep you in touch ASAP with a fix...
Until then don't hesitate to try the v2.0.0-beta that comes with some other fixes...

Best regards,
Anthodpnt

I have a doubt with the hard reload, url parameters can be used for pagination, http://example.com/listing and http://example.com/listing?page=2 share the same url but are not really the same pages and a transition could be nice.

Ok fine, well look at it and enable transition for same pathname with parameters !

Have a nice day,
Anthodpnt

I've just test the 1.3.9 release with url parameters and it does a full page reload every time I goes to an url with params (from index to index?param=1 or from index to page?param=1).

Here is my sample test files:

index.php
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Index</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="scripts/highway-1.3.9.js"></script>
</head>
<body router-wrapper>
    <div router-view="index">
        <?php echo $_SERVER['REQUEST_URI'] ?>
        <hr>
        <a href="page.php">Go to /page.php</a>
        <br>
        <a href="page.php?param=1">Go to /page.php?param=1</a>
        <br>
        <a href="index.php?param=new">Go to /index.php?param=new</a>
    </div>
    <script src="scripts/main.js"></script>
</body>
</html>
page.php
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="scripts/highway-1.3.9.js"></script>
</head>
<body router-wrapper>
    <div router-view="test-page">
        <?php echo $_SERVER['REQUEST_URI'] ?>
        <hr>
        <a href="index.php">Go to /index.php</a>
        <br>
        <a href="index.php?param=1">Go to /index.php?param=1</a>
        <br>
        <a href="page.php?param=new">Go to /page.php?param=new</a>
    </div>
    <script src="scripts/main.js"></script>
</body>
</html>

main.js only start Highway without options.

Hello @TristanPct ,
The fix provided is only a quick fix to avoid having no redirection at all.

For the moment it's not ideal but we are going to look deeper into this issue when time comes :-)

Best regards,
Thao

@TristanPct The release the v2.0.0 version of Highway will solve this issue. The transitions are now launched when parameters are added or removed from the URL even if the pathname is the same. You can find an example on the demo website.

Best regards,
Anthodpnt