[Opinion] Context Menu "Best Practices"

https://vaadin.com/docs/latest/components/context-menu/#best-practices
In the docs it says “You shouldn’t use [the context menu] as the only or primary means to complete a task.”

And then it provides an example on how to create a menu bar that resembles the context menu.

Now the API of the menu bar and context menu is different in multiple ways, and I just wonder why that is? Are you really supposed to basically replicate your menu through two different interfaces everywhere?

It basically forces everyone who wants a consistent layout to write a builder for menus that can both generate a similarly looking ContextMenu and a MenuBar.

[Opinion] Context Menu “Best Practices”

Simplest answer: accessibility. How should somebody without a mouse / right clicking possibility open the context menu? Or Discoverability - how should somebody know that here is a something hidden behind a context menu?

I understand that it’s required to make the contextmenu accessible somewhere without a right click… But why is there no API to just attach it to a button?

Why do I have to recreate the whole context menu using a API that works completely different (MenuBar)

Because…! No idea :grimacing: