XML error using sap.tnt.SideNavigation with loaded fragments

Viewed 104

Given a sap.tnt.ToolPage navigation bar with the sideContent bar, OpenUI5 1.98.0.

When navigating with the navigation bar I periodically observe the following error in the console:

Error: resource com/myApp/view/documents/Documents.view.xml could not be loaded from ./view/documents/Documents.view.xml. Check for 'file not found' or parse errors. Reason: Error: Invalid XML: This page contains the following errors: error on line 41 at column 3: Specification mandates value for attribute data-sap-ui-component

Below is a rendering of the page up to the first error.
    at Object.error (LoaderExtensions-dbg.js:339:15)
    at p (jquery-dbg.js:3500:29)
    at Object.fireWith [as rejectWith] (jquery-dbg.js:3630:7)
    at y3 (jquery-dbg.js:9913:13)
    at XMLHttpRequest.<anonymous> (jquery-dbg.js:10172:9)

The navigation bar sideContent is populated from the fragment:

<tnt:sideContent>

    <core:Fragment
        fragmentName = "com.myApp.view.fragment.SideNavigation"
        type = "XML" />

</tnt:sideContent>

The SideNavigation:

<SideNavigation
    xmlns:core = "sap.ui.core"
    xmlns = "sap.tnt"
    expanded = "true"
    id = "sideNavigation"
    selectedKey = "{/selectedKey}">

    <NavigationList items = "{
        path: '/navigation',
        templateShareable: false
    }">

        <core:Fragment
            fragmentName = "com.myApp.view.fragment.NavigationList"
            type = "XML" />

    </NavigationList>

    <fixedItem>

        <NavigationList
            items = "{
            path: '/fixedNavigation',
            templateShareable: false
        }">

            <core:Fragment
                fragmentName = "com.myApp.view.fragment.NavigationList"
                type = "XML" />

        </NavigationList>

    </fixedItem>

</SideNavigation>

The NavigationListItem:

<NavigationListItem
    xmlns = "sap.tnt"
    expanded = "{expanded}"
    href = "#/{key}"
    icon = "{icon}"
    items = "{
        path: 'items',
        templateShareable: false
    }"
    key = "{key}"
    text = "{
        path: 'titleI18NKey',
        formatter: '.formatter.getText'
    }">

    <NavigationListItem
        href = "#/{key}"
        key = "{key}"
        text = "{
            path: 'titleI18NKey',
            formatter: '.formatter.getText'
        }" />

</NavigationListItem>

Despite the warning regarding the invalid XML, the XML validators claim that the XML is correct. Another weird thing is that this error appears not at any click on the navigation bar but at the click on the specific items, while all the items are loaded from the JSON-model and are identical, minimum manually-written code.

I've tried to check deeper and find out that additionally I get an CSP error:

Refused to apply inline style because it violates the following Content Security Policy directive: "style-src https://*.hana.ondemand.com 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-ICa0DhwZQJsOd/Rn0N8H6FdQ71GfNL+op2zhAQ+Y4mM='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present.

But removal of the CSP completely doesn't solve the issue, therefore I don't think the CSP is the reason for the error.

Any way, it's quite strange to get an XML-error in case of a valid XML-template. Any idea what can lead to this error at clicking on the navigation side bar?

The the result, the navigation between the views is not always functioning, I assume, it might be an asynchronous view loading issue or something related more to how OpenUI5 operates, rather then to my custom code, since there is almost no custom code and the views are literally empty and contain only single title.

Perhaps, one more important thing, the navigation is defined in the model, initialized via manifest.json:

"sideNavigation": {
    "type": "sap.ui.model.json.JSONModel",
    "uri": "model/menus/sideNavigation.json"
}

sideNavigation:

{
    "selectedKey": "",

    "navigation": [
        {
            "icon": "sap-icon://home",
            "key": "index",
            "titleI18NKey": "Home"
        }
    ]
}

P.S. I've tried on 1.97.0 and 1.96.2, the same issue.

0 Answers
Related