Skip to content

Commit a5f7bea

Browse files
committed
Modify click behavior of nav panel item such that active items to not
cause the page to jump to the section.
1 parent c0fdd45 commit a5f7bea

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/libs/wdk-client/src/Views/Records/RecordNavigation/RecordNavigationItem.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ let RecordNavigationItem = ({ node, activeSection, onSectionToggle }) => {
2525
)}
2626
href={'#' + id}
2727
onClick={(event) => {
28-
const sectionIsActive =
29-
location.hash === event.target.getAttribute('href');
3028
if (isField) {
31-
onSectionToggle(id, sectionIsActive ? undefined : true);
29+
onSectionToggle(id, isActive ? undefined : true);
30+
return;
31+
}
32+
33+
// If the category is active, then do not jump to
34+
// its location on the page, but do allow the nav item
35+
// to toggle.
36+
if (isActive) {
37+
event.preventDefault();
3238
return;
3339
}
3440

@@ -38,7 +44,7 @@ let RecordNavigationItem = ({ node, activeSection, onSectionToggle }) => {
3844
// Prevent nav section toggle if the corresponding section is not active
3945
// and the nav section is expanded.
4046
// In other words, do not collapse the nav section if it is reselected.
41-
if (!sectionIsActive && navSectionIsExpanded) {
47+
if (navSectionIsExpanded) {
4248
event.stopPropagation();
4349
}
4450
}}

0 commit comments

Comments
 (0)