|
34 | 34 | TurboSession.turboFailedToLoad()
|
35 | 35 | }
|
36 | 36 |
|
37 |
| - visitLocationWithOptionsAndRestorationIdentifier(location, options, restorationIdentifier) { |
| 37 | + visitLocationWithOptionsAndRestorationIdentifier(location, optionsJSON, restorationIdentifier) { |
| 38 | + let options = JSON.parse(optionsJSON) |
| 39 | + let action = options.action |
| 40 | + |
38 | 41 | if (window.Turbo) {
|
39 |
| - Turbo.navigator.startVisit(location, restorationIdentifier, JSON.parse(options)) |
| 42 | + if (Turbo.navigator.locationWithActionIsSamePage(new URL(location), action)) { |
| 43 | + // Skip the same-page anchor scrolling behavior for visits initiated from the native |
| 44 | + // side. The page content may be stale and we want a fresh request from the network. |
| 45 | + Turbo.navigator.startVisit(location, restorationIdentifier, { "action": "replace" }) |
| 46 | + } else { |
| 47 | + Turbo.navigator.startVisit(location, restorationIdentifier, options) |
| 48 | + } |
40 | 49 | } else if (window.Turbolinks) {
|
41 | 50 | if (Turbolinks.controller.startVisitToLocationWithAction) {
|
42 | 51 | // Turbolinks 5
|
43 |
| - Turbolinks.controller.startVisitToLocationWithAction(location, JSON.parse(options).action, restorationIdentifier) |
| 52 | + Turbolinks.controller.startVisitToLocationWithAction(location, action, restorationIdentifier) |
44 | 53 | } else {
|
45 | 54 | // Turbolinks 5.3
|
46 |
| - Turbolinks.controller.startVisitToLocation(location, restorationIdentifier, JSON.parse(options)) |
| 55 | + Turbolinks.controller.startVisitToLocation(location, restorationIdentifier, options) |
47 | 56 | }
|
48 | 57 | }
|
49 | 58 | }
|
|
0 commit comments