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

RESOLVED INCOMPLETE

Status

()

Toolkit
XUL Widgets
RESOLVED INCOMPLETE
6 years ago
3 years ago

People

(Reporter: whaun, Unassigned)

Tracking

({testcase-wanted})

9 Branch
x86
Linux
testcase-wanted
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
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."

Comment 1

6 years ago
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
(Reporter)

Comment 2

6 years ago
(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;
  });

Comment 3

6 years ago
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
Last Resolved: 3 years ago
Flags: needinfo?(whaun)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.