Skip to content

Commit 2f46e58

Browse files
author
Dobromir Hristov
committed
fix: make navigator filter stick to bottom always.
1 parent bbc88b5 commit 2f46e58

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

src/components/Navigator.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="navigator">
2+
<div class="navigator" :style="{ '--sticky-top-offset': topOffset }">
33
<NavigatorCard
44
:technology="technology.title"
55
:kind="technology.kind"
@@ -48,8 +48,22 @@ export default {
4848
data() {
4949
return {
5050
filter: '',
51+
topOffset: '0px',
5152
};
5253
},
54+
mounted() {
55+
const anchor = document.getElementById('nav-sticky-anchor');
56+
if (anchor.offsetTop === 0) return;
57+
const cb = () => {
58+
const y = Math.max(document.getElementById('nav-sticky-anchor').getBoundingClientRect().y, 0);
59+
this.topOffset = `${y}px`;
60+
};
61+
window.addEventListener('scroll', cb);
62+
cb();
63+
this.$once('hook:beforeDestroy', () => {
64+
window.removeEventListener('scroll', cb);
65+
});
66+
},
5367
computed: {
5468
// filters the children based on the filter input
5569
filteredTree({ technology, filter }) {
@@ -91,14 +105,18 @@ export default {
91105
@import 'docc-render/styles/_core.scss';
92106
93107
.navigator {
94-
overflow: hidden auto;
95108
position: sticky;
96109
top: $nav-height;
97-
max-height: calc(100vh - #{$nav-height});
110+
max-height: calc(100vh - #{$nav-height} - var(--sticky-top-offset));
111+
height: 100%;
112+
padding-bottom: 50px;
113+
box-sizing: border-box;
98114
}
99115
100116
.navigator-filter {
101-
position: sticky;
117+
position: absolute;
118+
width: 100%;
119+
box-sizing: border-box;
102120
bottom: 0;
103121
z-index: 1;
104122
padding: 8px 20px;

src/components/Navigator/HighlightMatches.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
/**
99
* Component used to mark plain text, based on a provided matcher string.
1010
*/
11+
12+
import { escapeHtml } from 'docc-render/utils/strings';
13+
1114
export default {
1215
name: 'HighlightMatch',
1316
props: {
@@ -28,8 +31,8 @@ export default {
2831
* @return {string}
2932
*/
3033
parsedText: ({ matcher, text }) => (matcher
31-
? text.replace(matcher, match => `<span class="match">${match}</span>`)
32-
: text),
34+
? text.replace(matcher, match => `<span class="match">${escapeHtml(match)}</span>`)
35+
: escapeHtml(text)),
3336
},
3437
};
3538
</script>

src/components/Navigator/NavigatorCard.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export default {
6767
@import 'docc-render/styles/_core.scss';
6868
6969
.navigator-card {
70-
overflow: hidden;
70+
overflow: hidden auto;
71+
height: 100%;
7172
7273
.head-wrapper {
7374
padding: 10px 20px;

0 commit comments

Comments
 (0)