Location changes not respected when using History API
Hi,
the browser extension does not seem to recognize window.location changes made via History API, therefore annotations are not loaded when using pushState (e.g. in single page apps). I think listening to the popstate event and updating/reloading annotations accordingly should do the trick. Is there any way I can work around this? Is there an event I can trigger so that the browser extension reloads?
Thanks & Best Morris
Hello @morris,
The client indeed does not recognise location changes triggered via the history API. There is an issue related to this in the client's repository at https://github.com/hypothesis/client/issues/142 . There isn't currently an event that you can trigger to cause a reload of the browser extension or embedded client.
The client has a notion of being connected to one or more "frames" that display different URLs. In order to support this the client would need to listen for "popstate" events, somehow observe URL changes via pushState and replaceState (which IIRC do not trigger any events) and then notify the sidebar application about the frame metadata change.
This has been resolved. Hypothesis will now respond to client-side URL changes and update the loaded annotations appropriately.