fix(Storybook): reenable inspection tool for popup pages

Closes: #11110
This commit is contained in:
Michał Cieślak 2023-06-15 16:57:58 +02:00 committed by Lukáš Tinkl
parent ccaa1578d0
commit 65b5d411e9
1 changed files with 17 additions and 5 deletions

View File

@ -36,6 +36,7 @@ ApplicationWindow {
}
function performInspection() {
// Find the items to inspect on the current page
const getItems = typeName =>
InspectionUtils.findItemsByTypeName(
viewLoader.item, typeName)
@ -44,20 +45,31 @@ ApplicationWindow {
...getItems("Custom" + root.currentPage)
]
// Find lowest commont ancestor of found items
const lca = InspectionUtils.lowestCommonAncestor(
items, viewLoader.item)
if (!!lca && lca.Overlay.overlay.children.length > 0) {
activateInspection(lca.Overlay.overlay.children[0])
return
}
// Inspect lca
if (lca) {
activateInspection(lca.parent.contentItem === lca
? lca.parent : lca)
return
}
// Look for the item for inspection on the Overlay, skip items
// without contentItem which can be, for example, instance of
// Overlay.modal or Overlay.modeless
const overlayChildren = root.Overlay.overlay.children
for (let i = 0; i < overlayChildren.length; i++) {
const item = overlayChildren[i]
if (item.contentItem) {
activateInspection(item)
return
}
}
nothingToInspectDialog.open()
}
}