Skip to content

Commit 1704495

Browse files
authored
Merge pull request RedHatOfficial#388 from RedHatOfficial/fix/hash-link-overlay
fix: close overlay on mobile nav after hash link click
2 parents 070a695 + 822bd1f commit 1704495

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

static/js/page.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
document.addEventListener('DOMContentLoaded', function() {
2+
const mainNavHashLinks = document.querySelectorAll(
3+
'rh-navigation-primary-item[href^="#"], rh-navigation-primary-item > a[href^="#"]'
4+
);
5+
6+
// Close dropdowns after clicking an in-page link on mobile viewports
7+
for (let hashLink of mainNavHashLinks) {
8+
hashLink.addEventListener('click', function() {
9+
hashLink.closest('rh-navigation-primary').close();
10+
});
11+
}
12+
});

templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ <h3 class="header">{{ elem.heading }}</h3>
116116

117117
{% include "partials/_footer.html" %}
118118

119+
<script src="/js/page.js"></script>
119120
<script src="/js/table-search.js"></script>
120121
<script src="/js/rht-picture.js"></script>
121122

0 commit comments

Comments
 (0)