browser-extension icon indicating copy to clipboard operation
browser-extension copied to clipboard

Location changes not respected when using History API

Open morris opened this issue 8 years ago • 1 comments

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

morris avatar Sep 18 '17 12:09 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.

robertknight avatar Sep 18 '17 15:09 robertknight

This has been resolved. Hypothesis will now respond to client-side URL changes and update the loaded annotations appropriately.

robertknight avatar Apr 04 '23 14:04 robertknight