Duet3D / DuetWebControl

A completely new web interface for the Duet electronics
GNU General Public License v3.0
409 stars 231 forks source link

Added nextTick=>return to registerCategory function #449

Closed MintyTrebor closed 1 year ago

MintyTrebor commented 1 year ago

If a plugin attempts to register a new menu category using 'registerCategory', and then immediately attempts to register routes for child components of the new menu category, the menu does not update on screen. By adding a nextTick=>return to the 'registerCategory' function, it ensures the DOM/Component is updated before the child components are added, and the menu is updated on screen as expected.

chrishamm commented 1 year ago

I am surprised it works, because the callback inside Vue.nextTick is called when the DOM has been updated and you don't await the promise returned by it - see https://v2.vuejs.org/v2/api/#Vue-nextTick

I suppose something like

await Vue.nextTick(() => {});

in registerCategory would be safer.

Sindarius commented 1 year ago

You can do await Vue.nextTick() instead since the callback is optional and the promise is resolved after the DOM update.

MintyTrebor commented 1 year ago

I may have some more changes to make to this file so feel free to decline : I am trying to get the router to allow me to have multiple menu items going to the same component with different props, and the some of the router properties I may need are not defined in the MenuItem interface - so I may end up sending through another pull request.

MintyTrebor commented 1 year ago

closing - further updates needed