Jump to content

GenericUI plugin pages: menu highlight never moves (genericui.js getTitle throws before UI/View loads) – 4.10.


Go to solution Solved by Luke,

Recommended Posts

Brazer
Posted

Server / web app: Emby Server 4.10.1.0 (Windows and Linux/Docker), web client 4.10.1.0
Plugin: GenericEdit / PluginUI page (IHasUIPages, PluginPageInfo { EnableInMainMenu = true }), built against SDK 4.10.0.24-beta2

Symptom:
Clicking a GenericUI plugin page in the left menu opens the page, but the menu highlight stays on the previously viewed item. Plugins with their own HTML config pages (configurationpage?name=...) highlight correctly.

Cause (modules/genericui/genericui.js):

    View.prototype.getTitle = function () { return this.item.Caption || "" }

On viewshow, AppHeader.onViewShow -> BaseView.setTitle() -> getTitle() runs before fetchItem() (the UI/View request started in TabbedView.onBeginResume) has resolved, so this.item is still undefined and it throws:

Quote

    TypeError: Cannot read properties of undefined (reading 'Caption')
        at View.getTitle (modules/genericui/genericui.js?v=4.10.1.0:1:803)
        at BaseView.setTitle (modules/viewmanager/baseview.js?v=4.10.1.0:1:6349)
        at AppHeader.onViewShow (modules/appheader/appheader.js?v=4.10.1.0:1:16394)

The throw aborts the rest of AppHeader.onViewShow, so _navdrawer.onViewShow(e) and updateDrawerLayout() never run and the drawer never updates navMenuOption-selected. The menu item's NavMenuId (/genericui?PageId=...) matches the route correctly; the selection code is simply never reached.

Repro:
Open any page (e.g. Scheduled Tasks), then click a GenericUI plugin page in the menu. Scheduled Tasks stays highlighted and the error appears in the browser console. Happens on every first open of the view.

Suggested fix - null-check like BaseView.getTitle does:

    View.prototype.getTitle = function () { return (this.item && this.item.Caption) || "" }


(or set the title again once refreshItemPromise resolves).

Posted

Yes, a number of things are currently broken about it, unfortunately.

  • Solution
Posted

Hi, that fix has been added for the next release. Thanks.,

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...