Remove query w/o replacing URL using wix-location:to(path)

When navigating to a new path any query parameters are on the URL are kept. I need to remove them. The only way that seems to work is to replace the whole URL but that causes the page to blank white as a full page reload is done.

Is there a way to navigate to another page w/o the query params of previous page?

I have the same issue. I can’t find a better solution neither. For now, I have to code to set baseUrl + prefix / path every time when going to any page in order to make sure the query is clear. Very annoying!!

Hi,
Can you please send us a video of the issue using screencast ? Simply recreate the issue while recording the steps. Add the screencast.com URL to your response.

Thank you in advance,
Tal.

Hi Tal,

Here is the screencast. I highlighted the uri query in the video. And then I go to another page. The query will stay if I use wixLocation.to(‘/some-page’). The only way to clear it is to use:

const baseUrl = wixLocation.baseUrl;
wixLocation.to(${baseUrl}/some-page);

But I can’t code the Menu to direct the page. Therefore, the uri parameter cannot be cleared sometimes.

And btw: We do have a paid account. I am just using a free site for development before we go live.

Thanks for looking into this and have a great day!

Keawe

https://vimeo.com/261341958

@Tal

same problem here.

In additional, I have a page that sends an email via sendGrid. Just the first time I click the button sends the email. After that, I have to refresh the page to send another one.

any solution for this trouble?

Hi,
Thanks for the detailed videos. It seems like a bug. I’ve forwarded it to the relevant department. I’ll keep you posted once it is resolved.

Have a good day,
Tal.

Same problem for me.

Hi guys,
Currently, we don’t support removing query params from the URL. I’ve forwarded your feedback to the relevant department and we’ll update you if there’s a change with it.

Have a good day,
Tal.

Hi Tal,
This is a highly required and logical feature. My website link is getting annoyingly big because of this. The only solution now is to reload the page to remove the query parameter which takes lot of time.

Solution:

Develop a Wix.location.query.remove method.

Thanks.

Any updates here? This really is an annoying issue.

Hi,

This is a horrible thing - persisting querystrings between local page links can cause all sorts of unpredictable bugs.

To work around this, I am lucky, because only one of my pages ever gets landed on with a querystring, so this gives me the opportunity to remove the querystring when the user navigates away to another page on my site.

I do this by calling a small check function on my page script onReady(), which checks to see if a querystring needs to be reset, and then reloading THE SAME page again, with blank values for each query parameter - wix is clever enough not to reload the current page again, but it does update the URL with updated querystring values. Looks like this:

import wixLocation from 'wix-location';

export function resetQuerystring() {
  let query = wixLocation.query;
  let numQueries = Object.keys(query).length;
  if(numQueries > 0){
    if (query.id|| query.name|| query.loc|| query.dat) {
      let path = wixLocation.path;
      let prefix = wixLocation.prefix;
      console.log("found a query string value... resetting now");
      wixLocation.to("/" + prefix + "/" + path + "?id=&name=&loc=&dat=");
    }
  }
}

This forces the query values to be null and when the user navigates one more time, the querystrings are gone.

I realise it won’t work for everyone but maybe it will help.

Another alternative to prevent behaviour resulting from an unwanted/expired querystring would be to add a timestamp your querystrings, and then make a check for a valid timestamp before processing the queries - for example, only queries with a timestamp within the last 10 secs are processed, otherwise they are ignored.

Hope that helps.

A function for clearing querystrings in the wixLocation module would be really helpful, because as we’ve all said, forced sticky querystrings are nasty.