Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/routing/ActiveLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const ActiveLink = factory(function ActiveLink({
icache.set('handle', () => handle);
}
const context = router.getOutlet(to);
const isActive = context && paramsEqual(params, context.params);
const isActive = context && paramsEqual(params, { ...context.params, ...context.queryParams });
const contextIsExact = context && context.isExact();

classes = Array.isArray(classes) ? classes : [classes];
Expand Down
18 changes: 18 additions & 0 deletions tests/routing/unit/ActiveLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const router = new Router(
path: 'other',
outlet: 'other'
},
{
path: 'query/{path}?{query}',
outlet: 'query'
},
{
path: 'param',
outlet: 'param',
Expand Down Expand Up @@ -70,6 +74,20 @@ describe('ActiveLink', () => {
h.expect(() => w(Link, { classes: ['foo'], to: 'foo' }, ['hello']));
});

it('Should render the ActiveLink children when matching query params', () => {
router.setPath('/query/path?query=query');
const h = harness(
() =>
w(ActiveLink, { to: 'query', params: { path: 'path', query: 'query' }, activeClasses: ['foo'] }, [
'hello'
]),
{
middleware: [[getRegistry, mockGetRegistry]]
}
);
h.expect(() => w(Link, { classes: ['foo'], to: 'query', params: { path: 'path', query: 'query' } }, ['hello']));
});

it('Should mix the active class onto existing string class when the outlet is active', () => {
router.setPath('/foo');
const h = harness(() => w(ActiveLink, { to: 'foo', activeClasses: ['foo'], classes: 'bar' }), {
Expand Down