Opened 10 years ago

Closed 10 years ago

Last modified 6 years ago

#10268 closed defect (fixed)

Clear and focus on dijit.Editor doesn't work in Webkit

Reported by: chaitanya Owned by: Jared Jurkiewicz
Priority: high Milestone: 1.4
Component: Editor Version: 1.4.0b
Keywords: Cc:
Blocked By: Blocking:

Description

From the mail to the list:

In Webkit browsers, if I try to clear and bring focus back into the editing area of a dijit.Editor widget, the following code doesn't work (dojo toolkit 1.3.2):

editor.attr("value", "");
editor.focus();

This works in IE8 and Firefox though. I have to resort to this to get the desired behaviour:

editor.attr("value", " ");
editor.placeCursorAtStart();
editor.focus();

I think this is a bug. In particular, I don't like the fact that I have extra whitespace space in the editor. How can I avoid adding that extra whitespace?

Also, editor.focus() seems to work in Webkit if it is not immediately preceded by editor.attr("value", "...").

Attachments (1)

editor.html (1.2 KB) - added by chaitanya 10 years ago.
Testcase for clear and focus issue on Webkit

Download all attachments as: .zip

Change History (11)

Changed 10 years ago by chaitanya

Attachment: editor.html added

Testcase for clear and focus issue on Webkit

comment:1 Changed 10 years ago by chaitanya

Attached the testcase (editor.html).

The link "Clear and focus 1" calls the code above which is expected to work, but doesn't work in Webkit.

"Clear and focus 2" calls code which works on Webkit but adds an extra nbsp, besides needing to call placeCursorAtStart().

comment:2 Changed 10 years ago by Douglas Hays

Owner: set to Jared Jurkiewicz

comment:3 Changed 10 years ago by bill

It's strange because we already have this code in the editor, on 1.4:

// Use   to avoid webkit problems where editor is disabled until the user clicks it
if(!html && dojo.isWebkit){
	html = " ";
}

comment:4 Changed 10 years ago by chaitanya

That's because there's a typo in there -- should be dojo.isWebKit (notice the capital K). :)

Still, even fixing that doesn't make it work. You still have to call placeCursorAtStart() to bring the focus back into the editor.

comment:5 Changed 10 years ago by Jared Jurkiewicz

Fixing the typo works for me. The testfile works for both links and it focuses the editor properly and allows you to type.

I think you didn't clear your cache. :-)

I tested it on Google Chrome 3.0 and Safari 3.2.3 and have no issues once the typo was corrected.

The addition of the whitespace is currently necessary in order to allow focusing to work right.

comment:6 Changed 10 years ago by Jared Jurkiewicz

(In [20747]) Fixing typo of WebKit? check. \!strict refs #10268

comment:7 Changed 10 years ago by Jared Jurkiewicz

Resolution: fixed
Status: newclosed

(In [20752]) Make WebKit? focus to beginning programmatically. \!strict Doesn't remove the space, but focuses a bit better. fixes #10268

comment:8 Changed 10 years ago by chaitanya

Seems to work fine in trunk now (except for the extra space, of course). Thanks.

comment:9 Changed 10 years ago by bill

Milestone: tbd1.4

comment:10 Changed 6 years ago by Bill Keese <bill@…>

In ecc44bb321a5f3c3f88934e1d9c6b7286cdce728/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 
Note: See TracTickets for help on using tickets.