Skip to content

Commit

Permalink
Fix collapase menu and popup position (#12501)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeotero authored and QilongTang committed Jan 20, 2022
1 parent 3dbf969 commit 1155086
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ internal static void CollapseExpandPackage(Step stepInfo)
{
CurrentExecutingStep = stepInfo;
var firstUIAutomation = stepInfo.UIAutomation.FirstOrDefault();
if (firstUIAutomation == null) return;
if (firstUIAutomation == null || firstUIAutomation.JSParameters.Count == 0) return;
object[] parametersInvokeScript = new object[] { firstUIAutomation.JSFunctionName, new object[] { firstUIAutomation.JSParameters.FirstOrDefault() } };
ResourceUtilities.ExecuteJSFunction(stepInfo.MainWindow, stepInfo.HostPopupInfo, parametersInvokeScript);
}
Expand Down
28 changes: 22 additions & 6 deletions src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@
"Name": "SubscribeNextButtonClickEvent",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSParameters": [ "SampleLibraryUI" ],
"JSParameters": [ "SampleLibraryUI", "LibraryItemText" ],
"AutomaticHandlers": [
{
"HandlerElement": "NextButton",
Expand Down Expand Up @@ -795,7 +795,7 @@
"Type": "tooltip",
"TooltipPointerDirection": "top_left",
"Width": 480,
"Height": 490,
"Height": 400,
"ShowLibrary": true,
"StepContent": {
"Title": "PackagesGuidePackagesNodeTitle",
Expand All @@ -806,8 +806,8 @@
"DynamicHostWindow": true,
"HostUIElementString": "sidebarGrid",
"WindowName": "LibraryView",
"VerticalPopupOffset": 300,
"HorizontalPopupOffset": 300,
"VerticalPopupOffset": 450,
"HorizontalPopupOffset": 320,
"HtmlPage": {
"FileName": "nodePackage.html",
"Resources": {
Expand All @@ -830,7 +830,23 @@
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSParameters": [ "Revit" ]
"JSParameters": [ "SampleLibraryUI", "LibraryItemText" ]
},
{
"Sequence": 2,
"ControlType": "JSFunction",
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSParameters": [ "Examples", "LibraryItemGroupText" ]
},
{
"Sequence": 3,
"ControlType": "function",
"Name": "LibraryScrollToBottom",
"JSFunctionName": "scrollToBottom",
"JSParameters": [],
"Action": "execute"
}
]
},
Expand All @@ -853,7 +869,7 @@
"HostPopupInfo": {
"PopupPlacement": "center",
"HostUIElementString": "WorkspaceTabs",
"VerticalPopupOffset": 0
"VerticalPopupOffset": 0
}
}
]
Expand Down
10 changes: 5 additions & 5 deletions src/LibraryViewExtensionMSWebBrowser/web/library/library.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@
}

//This will find the <div> that contains the package information
function findPackageDiv(packageName) {
function findPackageDiv(packageName, libraryClassName) {
var found_div = null;
var libraryItemsText = document.getElementsByClassName("LibraryItemText");
var libraryItemsText = document.getElementsByClassName(libraryClassName);
for (var i = 0; i < libraryItemsText.length; i++) {
if (libraryItemsText[i].textContent.toLowerCase() == packageName.toLowerCase()) {
found_div = libraryItemsText[i];
Expand All @@ -321,13 +321,13 @@
}

//This will execute a click over a specific <div> that contains the package content
function collapseExpandPackage(packageName) {
var found_div = findPackageDiv(packageName);
function collapseExpandPackage(packageName, libraryClassName) {
var found_div = findPackageDiv(packageName, libraryClassName);
if (found_div == null) {
return;
}
var containerCatDiv = found_div.parentNode.parentNode;
var itemBodyContainer = containerCatDiv.getElementsByClassName("LibraryItemText")[0];
var itemBodyContainer = containerCatDiv.getElementsByClassName(libraryClassName)[0];
itemBodyContainer.click();
}

Expand Down

0 comments on commit 1155086

Please sign in to comment.