The history.location field doesn't update with @forge/bridge history object

I followed the guide on routing with a Custom UI:

The history.push() calls work as expected: the app navigates to the new page and the URL is updated.

However, the value of history.location doesn’t seem to update: it is always the value of the original URL entered in the browser, and doesn’t change following calls to history.push().

In my case I want to check the existing location before pushing new locations, as I want to carry over existing query parameters. To accomplish this, I have to manually listen for location changes:

  const [history, setHistory] = useState<History | null>(null);
  const [location, setLocation] = useState<Location | null>(null);

  useEffect(() => {
    view.createHistory().then((history) => {
      history.listen((location) => {
        console.log("location changed:", location); // this updates as expected
        console.log("history.location:", history.location); // this never changes
  }, []);

Am I missing something, or is this a bug in the framework? (I’m using @forge/bridge v2.0.0, currently the latest.)

1 Like

Hey @jbrunton,

Thanks for picking up on this. This sounds like a bug in the framework. We’ll have a look and see if we can implement a fix.