-
Notifications
You must be signed in to change notification settings - Fork 307
Open
Description
Here is the enhancement to standardize toggle behavior on click of left panel.
Params
render-style="focus"
on-nav-tag-click="show-description"
Current behavior
On click of left panel entry, right panel shows details. But to expand the item on left panel, user needs to click on arrow icon on right. Also, that does not collapse other items. This is inconvenient for users.
Proposed behavior
On click of left panel entry, do the following:
-Show details on right panel.
-Expand the item on left panel.
-Collapse any other open item/s on left panel.
Live example with proposed behavior: https://majoshi1.github.io/rapidocweb/examples/focused-mode.html
Below are all the changes needed for this proposed behavior.
In src\templates\navbar-template.js:
- Update navBarClickAndEnterHandler function.
From:
export function navBarClickAndEnterHandler(event) {
if (!(event.type === 'click' || (event.type === 'keyup' && event.keyCode === 13))) {
return;
}
const navEl = event.target;
event.stopPropagation();
if (navEl.dataset?.action === 'navigate') {
this.scrollToEventTarget(event, false);
} else if (navEl.dataset?.action === 'expand-all' || (navEl.dataset?.action === 'collapse-all')) {
expandCollapseAll(event, navEl.dataset.action);
} else if (navEl.dataset?.action === 'expand-collapse-tag') {
expandCollapseNavBarTag(navEl, 'toggle');
}
}
To:
export function navBarClickAndEnterHandler(event) {
if (!(event.type === 'click' || (event.type === 'keyup' && event.keyCode === 13))) {
return;
}
const navEl = event.target;
event.stopPropagation();
if (navEl.dataset?.action === 'navigate') {
this.scrollToEventTarget(event, false);
const tagAndPathEl = navEl?.closest('.nav-bar-tag-and-paths');
let wasExpanded = false;
if (tagAndPathEl) {
wasExpanded = tagAndPathEl.classList.contains('expanded');
}
expandCollapseAll(event, 'collapse-all');
expandCollapseNavBarTag(navEl, 'toggle');
if (wasExpanded) {
expandCollapseNavBarTag(navEl, 'toggle');
}
} else if (navEl.dataset?.action === 'expand-all' || (navEl.dataset?.action === 'collapse-all')) {
expandCollapseAll(event, navEl.dataset.action);
} else if (navEl.dataset?.action === 'expand-collapse-tag') {
expandCollapseNavBarTag(navEl, 'toggle');
}
}
- Update template to remove the behavior from the right arrow icon on left panel (as it is redundant).
From:
<div class='nav-bar-tag-icon' tabindex='0' data-action='expand-collapse-tag'></div>
To:
<div class='nav-bar-tag-icon' style="pointer-events:none;"></div>
Metadata
Metadata
Assignees
Labels
No labels