The improvements from @szyklos (eszkadev) around reducing code that is needed to show buttons (use "customtoolitem" to invoke actions instead of new widget implementation per button) is now merged:
This means that we can now leverage the map.dispatch(action) to share code in UI handlers (introduced in Introduce map.dispatch(action) to share code in UI handlers · CollaboraOnline/online@3144a9f · GitHub )
And thus, sharing code between notebookbar and menubar without constructing menubar classes is now possible.
Additionally this keeps the focus on map after the users clicks on those buttons.
TO DO: more conversions can be done later, to finally remove "menubartoolitem" (they create menubar object just for invoking actions)
Thanks Szymon!