Skip to content

Conversation

DmitiryPotychkin
Copy link
Contributor

@DmitiryPotychkin DmitiryPotychkin commented Jan 26, 2021

Add parameter skipLocationChange for not add certain location to location history stack.

  1. ht-navigation-list receive list of links, link may have parameter skipLocationChange
  2. Value of this parameter with other arguments passed to navigate service method navigateWithinApp and after it to navigate method
  3. if value of skipLocationChange is true than service Router will receive skipLocationChange: true in extras, and this location will not be added to location history stack after routing

@DmitiryPotychkin DmitiryPotychkin requested a review from a team as a code owner January 26, 2021 19:27
@codecov
Copy link

codecov bot commented Jan 26, 2021

Codecov Report

Merging #534 (1e8fd7f) into main (3b1f8be) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #534   +/-   ##
=======================================
  Coverage   85.57%   85.57%           
=======================================
  Files         758      758           
  Lines       15525    15525           
  Branches     1839     1839           
=======================================
  Hits        13285    13285           
  Misses       2209     2209           
  Partials       31       31           
Impacted Files Coverage Δ
...onents/src/navigation/navigation-list.component.ts 85.18% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b1f8be...1e8fd7f. Read the comment docs.

anandtiwary
anandtiwary previously approved these changes Jan 26, 2021
relativeTo?: ActivatedRoute,
preserveParameters?: string[]
preserveParameters?: string[],
skipLocationChange?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a shortcut method, instead of modifying this with more optional parameters, can you use navigate instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What will be better - create new method similar to navigateWithinApp in navigation service (maybe it'll be helpful in future or it's a rare case?) or just directly use navigate method inside navigation-list component without any shortcut?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave navigationService untouched, and call via:

  this.navigationService.navigate({
      navType: NavigationParamsType.InApp,
      path: item.matchPaths[0],
      replaceCurrentHistory: item.skipLocationChange,
      relativeTo: this.activatedRoute
  });

Replacing the history, when changing something other than a query param (which is already supported) should be a rare case. I'm not convinced we need it here, but I definitely don't want to encourage it for future use cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

(you beat me to this with the exact change 😄 )

queryParams?: QueryParamObject;
queryParamsHandling?: 'merge' | 'preserve';
relativeTo?: ActivatedRoute;
skipLocationChange?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is already captured on line 306 (replaceCurrentHistory)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks, will use it instead adding new

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld left a comment

Choose a reason for hiding this comment

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

Commented above

navType: NavigationParamsType.InApp,
path: item.matchPaths[0],
relativeTo: this.activatedRoute,
replaceCurrentHistory: item.skipLocationChange
Copy link
Contributor

Choose a reason for hiding this comment

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

So missed this the first time around, but we should clarify our naming (the test actually caught this). There's two separate booleans that the angular supports:

  • skipLocationChange: When true, navigates without pushing a new state into history.
  • replaceUrl: When true, navigates while replacing the current state in history.

To illustrate the distinction, imagine three nav items that are navigated in order (first -> second -> third)

first: { ...,  skipLocationChange: false},
second: { ...,  skipLocationChange: true},
third: { ...,  skipLocationChange: false}

with the behavior of skipLocationChange, when complete our history stack looks like:

<third> // Active
<first> // browser back

with the behavior of replaceUrl, when complete our history stack looks like:

<third> // Active
<second> // browser back

A subtle distinction, but our implementation uses replaceUrl, so we should name the item's property accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@DmitiryPotychkin can we update the naming here to reflect the behavior? In other words, skipLocationChange on line 124 should be named replaceCurrentHistory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aaron-steinfeld thank you for the explanation!

@aaron-steinfeld aaron-steinfeld merged commit 7ad445c into hypertrace:main Jan 27, 2021
@github-actions
Copy link

Unit Test Results

    4 files  ±0  232 suites  ±0   14m 16s ⏱️ ±0s
820 tests +2  820 ✔️ +2  0 💤 ±0  0 ❌ ±0 
824 runs  +2  824 ✔️ +2  0 💤 ±0  0 ❌ ±0 

Results for commit 7ad445c. ± Comparison against base commit 3b1f8be.

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.

3 participants