Skip to content

Commit bd891e5

Browse files
authored
Transform item's path to lowercase in navigator (#836)
Allows for the current technology to be selected in the navigator when on the associated page for it, regardless of the URL path casing. Resolves: rdar://122911237
1 parent 37bb387 commit bd891e5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/components/Navigator/NavigatorCard.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
v-if="technology"
3737
:id="INDEX_ROOT_KEY"
3838
:url="technologyPath"
39-
class="technology-title"
39+
:class="['technology-title', { 'router-link-exact-active': isTechnologyRoute }]"
4040
@click.alt.native.prevent="toggleAllNodes"
4141
>
4242
<h2 class="card-link">
@@ -247,6 +247,8 @@ export default {
247247
};
248248
},
249249
computed: {
250+
isTechnologyRoute: ({ technologyPath, $route }) => (
251+
technologyPath.toLowerCase() === $route.path.toLowerCase()),
250252
politeAriaLive() {
251253
const { hasNodes, navigatorItems } = this;
252254
if (!hasNodes) return '';

tests/unit/components/Navigator/NavigatorCard.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ const createWrapper = ({ propsData, ...others } = {}) => shallowMount(NavigatorC
189189
BaseNavigatorCard,
190190
},
191191
sync: false,
192+
mocks: { $route: { path: defaultProps.technologyPath } },
192193
attachToDocument: true,
193194
...others,
194195
});
@@ -370,6 +371,14 @@ describe('NavigatorCard', () => {
370371
});
371372
});
372373

374+
it('adds the "router-link-exact-active" class for case insensitive version of technologyPath', async () => {
375+
const wrapper = createWrapper();
376+
wrapper.setProps({
377+
technologyPath: '/documentation/Testkit',
378+
});
379+
expect(wrapper.find('.technology-title').classes()).toContain('router-link-exact-active');
380+
});
381+
373382
it('focus the first item if there is no active item', async () => {
374383
const wrapper = createWrapper();
375384
await flushPromises();

0 commit comments

Comments
 (0)