fix(router): make routerLinkActive work with query params which contain arrays (#22666)
The url_tree equalQueryParams and containsQueryParam methods did not handle query params that has arrays, which resulted in the routerLinkActive to not behave as expected, change was made to ensure query params with arrays are handled correctly fixes #22223 PR Close #22666
This commit is contained in:

committed by
Kara Erickson

parent
06e36e5972
commit
8e5ed203bc
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {PRIMARY_OUTLET, ParamMap, Params, convertToParamMap} from './shared';
|
||||
import {forEach, shallowEqual} from './utils/collection';
|
||||
import {equalArraysOrString, forEach, shallowEqual} from './utils/collection';
|
||||
|
||||
export function createEmptyUrlTree() {
|
||||
return new UrlTree(new UrlSegmentGroup([], {}), {}, null);
|
||||
@ -41,7 +41,7 @@ function equalSegmentGroups(container: UrlSegmentGroup, containee: UrlSegmentGro
|
||||
function containsQueryParams(container: Params, containee: Params): boolean {
|
||||
// TODO: This does not handle array params correctly.
|
||||
return Object.keys(containee).length <= Object.keys(container).length &&
|
||||
Object.keys(containee).every(key => containee[key] === container[key]);
|
||||
Object.keys(containee).every(key => equalArraysOrString(container[key], containee[key]));
|
||||
}
|
||||
|
||||
function containsSegmentGroup(container: UrlSegmentGroup, containee: UrlSegmentGroup): boolean {
|
||||
|
Reference in New Issue
Block a user