Skip to content

Commit 97e665e

Browse files
authored
Links to other declarations should include query params (#805) rdar://124041300
Links to other declarations should include query params (#805) rdar://124041300
1 parent 67ffe4a commit 97e665e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/components/DocumentationTopic/PrimaryContent/DeclarationGroup.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import Language from 'docc-render/constants/Language';
5353
import TransitionExpand from 'docc-render/components/TransitionExpand.vue';
5454
import { APIChangesMultipleLines } from 'docc-render/mixins/apiChangesHelpers';
5555
import { waitFor } from 'docc-render/utils/loading';
56+
import { buildUrl } from 'docc-render/utils/url-helper';
5657
5758
/**
5859
* Renders a code source with an optional caption.
@@ -162,7 +163,8 @@ export default {
162163
await this.$nextTick(); // wait for identifier to update
163164
this.isExpanded = false; // collapse the list
164165
await waitFor(500); // wait for animation to finish
165-
this.$router.push(this.references[identifier].url);
166+
const url = buildUrl(this.references[identifier].url, this.$route.query);
167+
this.$router.push(url);
166168
},
167169
getWrapperComponent(decl) {
168170
return (!this.isExpanded || decl.identifier === this.identifier)

tests/unit/components/DocumentationTopic/PrimaryContent/DeclarationGroup.spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ import { flushPromises } from '../../../../../test-utils';
1919
jest.mock('docc-render/utils/loading');
2020

2121
const mocks = {
22+
$route: {
23+
path: '/documentation/foo',
24+
query: {
25+
context: 'foo',
26+
},
27+
},
2228
$router: {
2329
push: jest.fn(),
2430
},
@@ -192,7 +198,7 @@ describe('DeclarationGroup with otherDeclarations', () => {
192198
expect(sourceWrapper.at(1).find('button').exists()).toBe(false);
193199
});
194200

195-
it('clicking on a pill from the expanded list selects that declaration', async () => {
201+
it('clicking on a pill from the expanded list selects that declaration with query param', async () => {
196202
const buttons = wrapper.findAll('.declaration-pill--expanded');
197203
const button = buttons.at(0).find('button');
198204
button.trigger('click');
@@ -203,6 +209,7 @@ describe('DeclarationGroup with otherDeclarations', () => {
203209
expect(wrapper.vm.selectedIdentifier).toEqual(identifier);
204210
expect(wrapper.emitted('update:declListExpanded')).toEqual([[false]]);
205211
expect(waitFor).toHaveBeenCalledWith(500); // wait for animation to be finish
206-
expect(mocks.$router.push).toHaveBeenCalledWith(store.state.references[identifier].url);
212+
const url = `${store.state.references[identifier].url}?context=foo`;
213+
expect(mocks.$router.push).toHaveBeenCalledWith(url);
207214
});
208215
});

0 commit comments

Comments
 (0)