Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#8688 closed defect (fixed)

Textarea: setValue() causes invalid focus on Safari

Reported by: liquidindigo Owned by: Douglas Hays
Priority: high Milestone: 1.3
Component: Dijit - Form Version: 1.2.3
Keywords: textarea setValue focus safari Cc: [email protected]
Blocked By: Blocking:


The setValue() and reset() methods of dijit.form.Textarea can cause invalid focus behavior on Safari. When working with the Textarea through an attached event handler, a call to setValue() causes the Textarea to appear to lose focus. Safari continues to highlight the Textarea, but it is impossible to type into the Textarea until clicking on the dijit. Calling focus() after the setValue() call has no effect.

A work-around to this problem is setting the text directly via dijit.byId(<some_id>).domNode.firstChild.firstChild.nodeValue. For this to work, it must follow a dojo.stopEvent(event) call.

In short, setValue() and reset() do not keep focus on the Textarea. Safari continues to highlight the Textarea, but typing is impossible until clicked on. Firefox and IE do not display this behavior and work as expected. It is not known whether the setValue() and reset() functions of other dijits also exhibit this behavior.

Attachments (1)

echo.html (1.7 KB) - added by liquidindigo 13 years ago.
A simple test of textarea behavior

Download all attachments as: .zip

Change History (6)

comment:1 Changed 13 years ago by bill

Summary: Textarea.setValue() causes invalid focus on SafariTextarea: setValue() causes invalid focus on Safari

I assume you are saying that when focus is on the widget and the user types something, it calls setValue() (btw you should be calling attr('value', ...) instead), and then the widget loses focus?

Can you attach a test case?

Changed 13 years ago by liquidindigo

Attachment: echo.html added

A simple test of textarea behavior

comment:2 Changed 13 years ago by liquidindigo

The attached file shows a simple test case. I attached an onKeyDown event to a textarea. When the Enter key is pressed, the value of the textarea is added to the DOM and the textarea is cleared.

On Firefox and IE, you can continue to type after submission. That is, once you hit enter, the textarea is cleared and focus remains on the textarea and you can continue typing without needing to move the mouse or use tab to focus. On Safari, after submission, the textarea is cleared and remains highlighted by the browser. However typing at this point is not echoed into the textarea. To type again, you must either click on the text area or select it using tab.

Note that in my attached file, I have my work around uncommented while the line that causes the behavior just described (setValue) commented out. Uncomment the setValue line to see the problem.

About your comment on attr, using attr did not change anything. In fact, using attr did not clear out the textarea. Perhaps I was misusing the function. Regardless, the documentation for Dojo 1.2 does not show setValue() as deprecated.

If there is any additional information I can provide, please let me know. I am new to this bug reporting business.

comment:3 Changed 13 years ago by bill

Owner: set to Douglas Hays

Thanks for the test case, looks good.

Doug, what do you think?

Another workaround would be to put your handler code in a setTimeout, so that it executes after the key press has finished processing. IIRC IE [also?] has some restrictions on what you can do in an event handler so I'm not sure it's kosher anyway to be changing the textarea's value as the keypress is coming in.

comment:4 Changed 13 years ago by Douglas Hays

Milestone: tbd1.3
Resolution: fixed
Status: newclosed

This is already fixed in the 1.3 trunk.

comment:5 Changed 11 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.