Allow ContextMenu to stay open when programmatically requested
Describe your motivation
When a ContextMenu is open, then some users would like to select a number of things in that menu. For example, one could want to pin a number of entries, comparable to a MultiSelectComboBox.
Describe the solution you'd like
contextMenu.setCloseOnInsideClick(false); contextMenu.setCloseOnOutsideClick(false); // the two lines above leave only contextMenu.close() // as the only option to close the context menu.
Describe alternatives you've considered
none
Additional context
This is requested by one of our customers who use this approach to pin several items in the ContextMenu. Their solution is brittle/error-prone because it is client-side and implementation-dependent. They would like official API for that.
Context menu items have a setKeepOpen API that keeps the menu open when they are clicked (#5398). There is no API to prevent closing on outside click though AFAIK.
@enver-haase, would setKeepOpen suit customer request or would prevention of closing on outside click be needed as well?
Yes, the prevention of closing on outside click would be needed as well.
Customer just realised that a context menu at this time even closes when there is a TextField added as a component and they try to navigate the cursor to the left within the TextField.
So, CURSOR-LEFT shall also not blindly and automatically close the context menu.
Context menu items have a
setKeepOpenAPI that keeps the menu open when they are clicked (#5398). There is no API to prevent closing on outside click though AFAIK.
Do I see that right that while 23.3.3 has it and 24.x has it, it is missing in 23.3.30 and 23.3.32, for example?!
Customer also realised that right-clicking closes -- also not wished for.
Suggestion is to have a ContextMenu-wide solution rather than fine-grained individual solutions on MenuItem level.