Skip to content

fix(location-strategy): find the correct outlet when navigating back and forward #1404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 4, 2018

Conversation

ADjenkov
Copy link
Contributor

@ADjenkov ADjenkov commented Jun 27, 2018

  • Extend FrameService to return the correct topmost frame

    When using TabView, with multiple tabs that have <p-r-o>, the topmost frame will currently return the root <p-r-o> for the current tab item even if there is a child <p-r-o> (even it is the last navigated frame). This will affect back navigation.

  • Extend FrameService to maintain <p-r-o> frames

  • Modify ns-location-strategy to mark the correct outlet state as isPageNavigation

    In order to recognize the correct currentOutlet, when navigating back and forward, we bind outlets names with their unique Frames and parent outlets (since there could be outlets with the same names but different frame instances).

    Knowing the parent outlet, along with its frame, helps us distinguish root and child outlets

    Modal view from different tab item issue: When using TabView with multiple tabs that have <p-r-o> the currentOutlet will be the last <p-r-o> that was navigated. This could be wrong since we could be landing on some other tab and decide to show Modal view from it. We need to mark the correct outlet state as isModalNavigation (the outlet from in which the modal view is shown) otherwise the wrong router states will be removed later on (and some other bad things).

    When opening modal view we pass the Frame from which the modal view was shown and search for it ( from our Frames collection) in order to find the correct outlet

  • Add e2e tests for modal-navigation scenarios

  • TO DO: Extend ns-location-strategy unit tests

ADjenkov added 2 commits June 27, 2018 13:25
FrameServices should be responsible for delivering the correct topmost frame too
@ADjenkov ADjenkov added the bug label Jun 27, 2018
@ADjenkov ADjenkov self-assigned this Jun 27, 2018
@ghost ghost added the in progress label Jun 27, 2018
@ADjenkov ADjenkov force-pushed the djenkov/location-strategy branch from 4cef7df to 905e3df Compare June 27, 2018 13:03
@ADjenkov
Copy link
Contributor Author

ADjenkov commented Jul 2, 2018

test android#4.2.0-2018-06-18-02

MartoYankov
MartoYankov previously approved these changes Jul 2, 2018
@ADjenkov
Copy link
Contributor Author

ADjenkov commented Jul 2, 2018

test

@ADjenkov
Copy link
Contributor Author

ADjenkov commented Jul 2, 2018

run ci

getFrame(): Frame {
return topmost();
let tompostFrame = topmost();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tompostFrame -> topmostFrame typo

@@ -134,11 +134,11 @@ function createState(url: string,

function simulatePageNavigation(strategy: NSLocationStrategy, url: string, outletName: string) {
strategy.pushState(null, null, url, null);
strategy._beginPageNavigation(outletName);
strategy._beginPageNavigation(outletName, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to explicitly pass null here to clarify or it can be an optional param?

const { cachedFrame, cachedFrameRootOutlet } = this.findFrame(topmostFrame);

if (cachedFrame && cachedFrameRootOutlet) {
const latestFrameByOutlet = this.getLatestFrameByOutlet(cachedFrameRootOutlet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a better name would be topmostFrameByOutlet (for variable and method)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

if (cachedFrame && cachedFrameRootOutlet) {
const latestFrameByOutlet = this.getLatestFrameByOutlet(cachedFrameRootOutlet);

if (latestFrameByOutlet && latestFrameByOutlet !== cachedFrame) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the scenario where we do not have latestFrameByOutlet -- can we add it as a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

@ADjenkov ADjenkov force-pushed the djenkov/location-strategy branch from 2a92e9f to 2eabf23 Compare July 3, 2018 12:11
…ativescript-angular into djenkov/location-strategy
@ADjenkov ADjenkov force-pushed the djenkov/location-strategy branch from 2eabf23 to e5f1663 Compare July 3, 2018 12:19
@ADjenkov ADjenkov merged commit f0119a0 into master Jul 4, 2018
@ghost ghost removed bug in progress labels Jul 4, 2018
@ADjenkov ADjenkov deleted the djenkov/location-strategy branch July 4, 2018 14:15
@NathanWalker
Copy link
Contributor

@ADjenkov it appears this commit may have broken routing badly in all existing apps - perhaps you can ping us on {N} community slack and we can provide more details. Too deep to post example for.

@NathanWalker
Copy link
Contributor

For anyone whom is using ~6.1.0 release and your routing is terribly unreliable/broken it's related to this commit and you can fix it by pinning your project to the build right before this commit went in:
"nativescript-angular": "6.1.0-2018-07-03-01",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants