in src/UXClient/Components/HierarchyNavigation/HierarchyNavigation.ts [47:101]
constructor(renderTarget: Element) {
super(renderTarget);
function isTarget() {
return d3.event.target === this || this.contains(d3.event.target);
}
d3.select("html").on("click. keydown." + Utils.guid(), () => {
//close hierarchy selection dropdown or context menu if necessary
if (this.clickedInstance && this.contextMenu) {
if (d3.event.type && d3.event.type === "keydown") {
if (!this.contextMenu.filter(isTarget).empty()) {
let key = d3.event.which || d3.event.keyCode;
if (key === KeyCodes.Esc) {
// close context menu when pressed esc on it
this.closeContextMenu();
}
return;
}
} else {
if (this.contextMenu.filter(isTarget).empty()) {
// close context menu when clicked any other target outside of it
this.closeContextMenu();
}
}
}
if (this.isHierarchySelectionActive) {
if (d3.event && d3.event.type && d3.event.type === "keydown") {
if (
!d3
.select(this.hierarchyListWrapperElem.node().parentNode)
.filter(isTarget)
.empty()
) {
let key = d3.event.which || d3.event.keyCode;
if (key === KeyCodes.Esc) {
// close hierarchy selection dropdown when pressed esc on it
this.isHierarchySelectionActive = false;
this.hierarchyListWrapperElem.style("display", "none");
}
return;
}
} else {
if (
d3
.select(this.hierarchyListWrapperElem.node().parentNode)
.filter(isTarget)
.empty()
) {
// close hierarchy selection dropdown when clicked any other target outside of it
this.isHierarchySelectionActive = false;
this.hierarchyListWrapperElem.style("display", "none");
}
}
}
});
}