fix($state): reloadOnSearch should not affect non-search param changes. #1962
+57
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The handling of
reloadOnSearch: false
caused ui-router to avoidreloading the state in more cases than it should. The designed and
documented behavior of this flag is to avoid state reload when the
URL search string changes. It was also avoiding state reload when
the URL path (or any non-search parameters to the state) changed,
and even when state reload was explicitly requested.
This change
boolean, skipTriggerReloadCheck) to match the direction of the
logic: shouldSkipReload and allowSkipReloadCheck
parameters, and only skip the reload if the only parameters that
differ were search parameters
boolean expression. (I think calling $state.reload() explicitly
should reload a state even if it has reloadOnSearch:false. But I
don't understand exactly why the test for this was where it was, and
maybe there's a good reason I'm missing. Also, if the behavior I
favor is deemed correct, we could also achieve that by setting
allowSkipReloadCheck=false for all truthy values of options.reload,
namely, if options.reload===true, and then shouldSkipReload wouldn't
even need to look at options. I left a comment about this in the
source too and would appreciate feedback.)
Fixes #1079. Helps with one of the cases broken in #582.