Commit 3abd2b1
authored
fix(history): store index of current history stack entry in the browser location state (#61)
Previously the history stack entries contained only an `id` referring to a history, while the entries and current index were stored in session storage. As in #59, this is not enough information to reliably determine which entry is currently active. For example, when the user uses the browser back/forward buttons (which can travel across multiple history states at once). Here the current index has been moved from the session storage to the state of each browser history entry. Since the combination of session ID and session entry index uniquely identifies and entry, the correct entry can be selected from the saved stack in session storage in all circumstances, given the contents of the current history state which can be read from the browser.
## Specific changes
- Remove behaviours for browsers not supporting the history API or session storage. They didn't work in the same way, and those browsers are now very very old (e.g. IE9)
- Remove workaround for an edge case where navigating away from the app and back again could cause Rudy to autonomously navigate away from the app a second time. The workaround didn't work in all cases (e.g. if the user manually typed a new URL into the address bar), and is no longer necessary now that the underlying bugs is fixed.
- Remove the behaviour of clearing subsequent entries in the saved history stack when loading the app fresh somewhere in the middle of the stack. The logic underlying this is not sound, because it is possible to traverse multiple entries in the history stack (arriving at entry 2/5 does not mean that entries 3-4 are not still in the future). This way it is still possible for there to be future entries in the rudy/redux state that don't correspond with the browsers future states, but a least navigation will always work correctly. Trying to go forwards via rudy beyond the history entries that the browser agrees with still works, in the sense that it correctly navigates to wherever is next in the browser's history stack (Rudy has no choice about that)
- Replace existing logic to guess the direction/distance of a browser initiated pop now that the correct index is available in the pop state
- Add a new test covering browser initiated pops, including where multiple entries are traversed at once
BREAKING CHANGE: browsers that don't support the history API or session storage are no longer supported at all. In practice this means IE9 is no longer supported.
BREAKING CHANGE: future entries in the history stack remain even if the user has since navigated from a previous entry to an external site (because they are no longer removed when they are potentially still the future entries in the browser stack)
Fixes #591 parent 51ff994 commit 3abd2b1
46 files changed
Lines changed: 1891 additions & 3005 deletions
File tree
- packages
- integration-tests
- __helpers__
- __tests__/integration/browser
- actionsInCallbacks/__snapshots__
- history
- __snapshots__
- pop/__snapshots__
- sessionStorage
- __snapshots__
- react/src/utils
- rudy/src
- core
- history
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
184 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
185 | 189 | | |
186 | | - | |
| 190 | + | |
187 | 191 | | |
188 | 192 | | |
189 | 193 | | |
| |||
374 | 378 | | |
375 | 379 | | |
376 | 380 | | |
| 381 | + | |
377 | 382 | | |
378 | 383 | | |
379 | 384 | | |
| |||
401 | 406 | | |
402 | 407 | | |
403 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
404 | 413 | | |
405 | 414 | | |
406 | 415 | | |
| |||
476 | 485 | | |
477 | 486 | | |
478 | 487 | | |
479 | | - | |
480 | | - | |
| 488 | + | |
481 | 489 | | |
482 | 490 | | |
483 | 491 | | |
| |||
Lines changed: 28 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
| |||
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
113 | | - | |
114 | 120 | | |
115 | 121 | | |
116 | 122 | | |
| |||
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
213 | 226 | | |
214 | 227 | | |
215 | 228 | | |
| |||
341 | 354 | | |
342 | 355 | | |
343 | 356 | | |
344 | | - | |
345 | 357 | | |
346 | 358 | | |
347 | 359 | | |
| |||
411 | 423 | | |
412 | 424 | | |
413 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
414 | 433 | | |
415 | 434 | | |
416 | 435 | | |
| |||
501 | 520 | | |
502 | 521 | | |
503 | 522 | | |
504 | | - | |
505 | 523 | | |
506 | 524 | | |
507 | 525 | | |
| |||
586 | 604 | | |
587 | 605 | | |
588 | 606 | | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
589 | 614 | | |
590 | 615 | | |
591 | 616 | | |
| |||
717 | 742 | | |
718 | 743 | | |
719 | 744 | | |
720 | | - | |
721 | 745 | | |
722 | 746 | | |
723 | 747 | | |
| |||
Lines changed: 56 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
| |||
222 | 229 | | |
223 | 230 | | |
224 | 231 | | |
225 | | - | |
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| |||
337 | 343 | | |
338 | 344 | | |
339 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
340 | 353 | | |
341 | 354 | | |
342 | 355 | | |
| |||
487 | 500 | | |
488 | 501 | | |
489 | 502 | | |
490 | | - | |
491 | 503 | | |
492 | 504 | | |
493 | 505 | | |
| |||
617 | 629 | | |
618 | 630 | | |
619 | 631 | | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
620 | 639 | | |
621 | 640 | | |
622 | 641 | | |
| |||
818 | 837 | | |
819 | 838 | | |
820 | 839 | | |
821 | | - | |
822 | 840 | | |
823 | 841 | | |
824 | 842 | | |
| |||
924 | 942 | | |
925 | 943 | | |
926 | 944 | | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
927 | 952 | | |
928 | 953 | | |
929 | 954 | | |
| |||
1140 | 1165 | | |
1141 | 1166 | | |
1142 | 1167 | | |
1143 | | - | |
1144 | 1168 | | |
1145 | 1169 | | |
1146 | 1170 | | |
| |||
1255 | 1279 | | |
1256 | 1280 | | |
1257 | 1281 | | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1258 | 1289 | | |
1259 | 1290 | | |
1260 | 1291 | | |
| |||
1385 | 1416 | | |
1386 | 1417 | | |
1387 | 1418 | | |
1388 | | - | |
1389 | 1419 | | |
1390 | 1420 | | |
1391 | 1421 | | |
| |||
1500 | 1530 | | |
1501 | 1531 | | |
1502 | 1532 | | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
1503 | 1540 | | |
1504 | 1541 | | |
1505 | 1542 | | |
| |||
1701 | 1738 | | |
1702 | 1739 | | |
1703 | 1740 | | |
1704 | | - | |
1705 | 1741 | | |
1706 | 1742 | | |
1707 | 1743 | | |
| |||
1801 | 1837 | | |
1802 | 1838 | | |
1803 | 1839 | | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
1804 | 1847 | | |
1805 | 1848 | | |
1806 | 1849 | | |
| |||
1916 | 1959 | | |
1917 | 1960 | | |
1918 | 1961 | | |
1919 | | - | |
1920 | 1962 | | |
1921 | 1963 | | |
1922 | 1964 | | |
| |||
2016 | 2058 | | |
2017 | 2059 | | |
2018 | 2060 | | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
2019 | 2068 | | |
2020 | 2069 | | |
2021 | 2070 | | |
| |||
2217 | 2266 | | |
2218 | 2267 | | |
2219 | 2268 | | |
2220 | | - | |
2221 | 2269 | | |
2222 | 2270 | | |
2223 | 2271 | | |
| |||
0 commit comments