Ticket #6226 (closed enhancement: wontfix)

Opened 8 months ago

Last modified 30 hours ago

Menu: API enhancements

Reported by: alex Owned by: bill
Priority: normal Milestone: 1.4
Component: Dijit Version: 1.0
Severity: normal Keywords: menu, dijit
Cc:

Description (last modified by bill) (diff)

I've been working with dijit.Menu this evening, and it's really making me scratch my head about a couple of design choices.

First, there's no open() or close() methods. Instead, one must pass an instance of the Menu into dijit.popup.open() or dijit.popup.close(). This is (to say the least) unintuitive.

Secondly, I expect that menus will be re-used often, and while there's a programmatic example of adding items to a menu, no example is provided for how to remove them, nor is there a "clear()" method or similar for removing dijit.MenuItem?() instance. Similarly, there isn't a uniform "remove from parent" (not destroy()) method on MenuItem? instances.

Lastly, it would seem that the construction of a set of menu items is the common case. Supporting a JSON-style syntax for describing a set of items and their generic properties seems useful for constructing trees of menus.

Change History

  Changed 8 months ago by bill

  • owner set to bill
  • summary changed from dijit.Menu API oddities to Menu: API enhancements
  • milestone changed from 1.2 to 1.4

The open()/close() thing is by design, a fallout from Dylan's idea that any widget should be able to be used as a popup.. thus widgets themselves don't have open/close methods. Will consider the other stuff.

in reply to: ↑ description   Changed 30 hours ago by bill

  • status changed from new to closed
  • type changed from defect to enhancement
  • resolution set to wontfix
  • description modified (diff)

Replying to alex:

Secondly, I expect that menus will be re-used often, and while there's a programmatic example of adding items to a menu, no example is provided for how to remove them, nor is there a "clear()" method or similar for removing dijit.MenuItem?() instance. Similarly, there isn't a uniform "remove from parent" (not destroy()) method on MenuItem? instances.

Menu.removeChild(MenuItem?) should work, doesn't it?

Lastly, it would seem that the construction of a set of menu items is the common case. Supporting a JSON-style syntax for describing a set of items and their generic properties seems useful for constructing trees of menus.

I agree that's a common case, although it can easily be done by code outside of menu. I don't see the benefit of adding it to Menu itself, although that's debatable. There's also a possibility of dojo.data integration... if you think about it Menus and Trees are similar in their hierarchical structure, and trees work off of dojo.data.

Anyway, I'm going to close this ER for now.

Note: See TracTickets for help on using tickets.