Closed Bug 576618 Opened 16 years ago Closed 16 years ago

XUL textboxes are not enabled by setting the attribute "disabled" to false

Categories

(Core :: XUL, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: mail-shredder, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 When you enable a textbox by setting the attribute "disabled" to false, the textbox will not become editable. If you set the property "disabled" to false everything works as expected. Reproducible: Always Steps to Reproduce: 1. Create a XUL file containing <textbox id="tb2" disabled="true" value="Something"/> 2. In Javascript do document.getElementById("tb2").setAttribute("disabled", false); Actual Results: The textbox looks like it has been enabled but still behaves as if disabled. It doesn't get the focus, you can't enter text, you can't select anything with the mouse and there is no context menu. Expected Results: The textbox should be editable like it would when you did document.getElementById("tb2").disabled = false; The documentation (https://developer.mozilla.org/en/XUL/textbox#a-disabled) states that using the property is the prefered way to enable a textbox. But that prevents the use of broadcasters to control "disabled" since they seem only to work with attributes. If they worked with properties this would not be an issue, but as far as I know, they don't. And finally a complete example: <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="onLoad();"> <script> function onLoad() { // Works. document.getElementById("tb1").disabled = false; // Doesn't work. The textbox has been visually enabled but is still not editable. document.getElementById("tb2").setAttribute("disabled", false); } </script> <textbox id="tb1" disabled="true" value="Enabled using the property 'disabled'. Works."/> <textbox id="tb2" disabled="true" value="Enabled using the attribute 'disabled'. Doesn't work. The textbox has been visually enabled but is still not editable."/> </window>
"disabled" is a binary attribute. It works just like HTML binary attributes: if the attribute is set, no matter what string value it's set to, it's treated as "true". To set it to false you removeAttribute.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.