Closed Bug 718669 Opened 12 years ago Closed 9 years ago

Dynamically created XUL radiogroups do not properly reset (selectedIndex = -1).

Categories

(Toolkit :: UI Widgets, defect)

9 Branch
x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: whaun, Unassigned)

Details

(Keywords: testcase-wanted)

User Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
Build ID: 20111220165912

Steps to reproduce:

Wrote a plugin that dynamically created and added radiogroups ("document.createElement") elements. One feature of the plugin resets all selections, including radiogroup selections. This was done by setting the radiogroups' "selectedIndex" property to -1 as specified in the documentation.


Actual results:

When setting the dynamically created radiogroups' "selectedIndex" property to -1, the prior selection persisted. The selected radio button stayed selected and also persisted as the radiogroup's "selectedItem" property. This behavior did not occur on pre-defined radiogroups, ones that were specified in the xul file.


Expected results:

The radiogroups' selection should reset, no member radio buttons should be selected and the "selectedItem" property should be "null."
Did you insert the newly created elements into the DOM before using their properties? Do you have a test XUL file we can use to reproduce?
Component: Untriaged → XUL Widgets
Keywords: testcase-wanted
Product: Firefox → Toolkit
QA Contact: untriaged → xul.widgets
(In reply to Nickolay_Ponomarev from comment #1)
> Did you insert the newly created elements into the DOM before using their
> properties? Do you have a test XUL file we can use to reproduce?

I will need to see if I can track down the old code. The radiogroups were not in a XUL file since they were dynamically created.

The creation code generally looked like this:

  [/*list of objects describing radiogroups*/].forEach(function (rdgInfo) {
      var rdg = document.createElement('radiogroup');
      e.setAttribute('id', rdgInfo.id);
      e.buttons.forEach(function (b) {
          var btn = document.createElement('radiobutton');
          btn.setAttribute('label', b.label);
          btn.setAttribute('value', b.value);
          rdg.appendChild(btn);
      }); 
      document.getElementById('parentNode').appendChild(rdg);
  });

The code to reset the selections looked like this:
  [/*list of radiogroup ids*/].forEach(function (id) { 
      document.getElementById(id).selectedIndex = -1;
  });
OK, I see what you mean. I can take a look if someone attaches a testcase, but don't feel obliged to make one.

For the reference:
http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/radio.xml#90
https://developer.mozilla.org/en/XUL/radiogroup#p-selectedIndex
Does this still reproduce?
Flags: needinfo?(whaun)
Closing this as incomplete due to inactivity and the lack of a reproducible test case. Feel free to reopen the bug if there's an updated testcase that still reproduces the issue.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Flags: needinfo?(whaun)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.