Open Bug 275737 Opened 20 years ago Updated 2 years ago

removing menulist children causes errors

Categories

(Core :: XUL, defect)

1.7 Branch
Other
Linux
defect

Tracking

()

UNCONFIRMED

People

(Reporter: sean, Unassigned)

Details

menulist.removechild(menulist.selectedItem) does not reset the value of
menulist. It retains its label, and errors the next time you click the dropdown.

Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
[nsIMenuBoxObject.activeChild]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)" 
location: "JS frame :: chrome://global/content/bindings/menulist.xml ::
onxblpopupshowing :: line 35"  data: no
Component: General → XP Apps: GUI Features
Assignee: general → nobody
Component: XP Apps: GUI Features → XP Toolkit/Widgets: Menus
Product: Mozilla Application Suite → Core
QA Contact: general
Removing the selected item is not nice in any widget...

So, any suggestions as to the "correct" fix?
1. Just bulletproof the activeChild logic
2. Write an XBL destructor for menuitems to deselect them
3. Write a C++ destructor for menuitems to deselect them
I don't really know enough about how menulists are set up to tell which of those is best....
Would it be as simple as placing a destructor in
toolkit/content/widgets/menu.xml#menuitem-base ?

<destructor>
  if this.isSameNode(parentNode.selectedItem)
    parentNode.selectedIndex=-1;
</destructor>
That is a (failed) attempt at case 2, yes...
In an email bz seems to prefer option 3. This would involve adding a check to
the selectedItem getter to check that the item's parent is still the menulist.
Component: XP Toolkit/Widgets: Menus → XUL
QA Contact: xptoolkit.widgets
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.