Skip to content

Commit 8894c45

Browse files
authored
Merge pull request #2555 from jowlo/feature/fix-multi-location-back-button
Fix browser back button with multiple dcc.Location components in layout
2 parents ebc6988 + 33ce4ea commit 8894c45

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66

77
## Fixed
88

9+
- [#2555](https://github.com/plotly/dash/pull/2555) Fix browser back button when removing one of multiple location components from layout, fix [#1312](https://github.com/plotly/dash/issues/1312)
910
- [#2565](https://github.com/plotly/dash/pull/2565) Fix sorting for > 10 pages, fix [#2564](https://github.com/plotly/dash/issues/2564)
1011

1112
## [2.10.2] - 2023-05-31

components/dash-core-components/src/components/Location.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class Location extends Component {
112112
}
113113

114114
componentDidMount() {
115-
window.onpopstate = this.onLocationChange;
115+
window.addEventListener('popstate', this.onLocationChange);
116116

117117
window.addEventListener(
118118
'_dashprivate_pushstate',
@@ -122,7 +122,7 @@ export default class Location extends Component {
122122
}
123123

124124
componentWillUnmount() {
125-
window.onpopstate = () => {};
125+
window.removeEventListener('popstate', this.onLocationChange);
126126
window.removeEventListener(
127127
'_dashprivate_pushstate',
128128
this.onLocationChange

0 commit comments

Comments
 (0)