Uh oh!
There was an error while loading. Please reload this page.
Use new @plotly/dash-component-plugins to handle location path changes - #743
Conversation
…ponents - use component plugins to emit global event from location component
Uh oh!
There was an error while loading. Please reload this page.
| } else { | ||
| window.history.pushState({}, '', href); | ||
| window.dispatchEvent(new CustomEvent('onpushstate')); | ||
| window.dispatchEvent(new CustomEvent('_dashprivate_onpushstate')); |
There was a problem hiding this comment.
Make the link <--> location event explicitly private. No one outside of DCC should listen to this.
| window.addEventListener( | ||
| '_dashprivate_onpushstate', | ||
| this.onLocationChange | ||
| ); |
There was a problem hiding this comment.
Location triggers a location changed event on both (1) click on dcc.Link with refresh=false (default), (2) user clicking back and forward buttons in the browser UI. Prior to this change it was only possible to listen for (1) with "onpushstate"
There was a problem hiding this comment.
nice
the location history feature is working well
| window.addEventListener( | ||
| '_dashprivate_onpushstate', | ||
| this.onLocationChange | ||
| ); |
There was a problem hiding this comment.
nice
the location history feature is working well
| ) | ||
| assert link_counter == 1 | ||
| assert history_counter == 1 |
There was a problem hiding this comment.
Simple test making sure the events are being triggered by the components
Linked to plotly/dash#1094