2010/07/01

Does Android 2.2 support contentEditable?

In Android 2.1 the browser doesn't support the contentEditable attribute for elements, meaning that it's not possible to use WYSIWYG editors in web pages because the virtual keyboard won't popup to write your texts (lots of other operations can be done by manipulating the DOM, but also providing a virtual keyboard might be too much).

One important problem with that status is that although contentEditable doesn't work, isContentEditable does return the "correct" value, and it states that such elements are editable although they aren't so it can't be used to find out if the browser doesn't support contentEditable and when they release a new version enable it automatically.

So I filed a ticket about this some weeks ago, and yesterday I got a notification stating that Android 2.2 a.k.a. FroYo does support contentEditable!

Those are good news, really good news. If it's true, you can expect to see support for your Android phone shortly in editors like CKEditor, TinyMCE, YahooUI,... and apps like GMail, Google Docs....

Anyway, I'm still unsure about that statement, currently I'm using FRF83, that's not the final build because now I'm waiting for the OTA as they said that we should get it during this week, but I've been doing quick tests with the previous builds and I didn't notice any change in the behavior.

You can test it right below. If it works, clicking after the "type here" paragraph should put the caret there and enable the keyboard, and clicking the link should not open the Google home page, let me know if it works in your phone.

Type here.., a link (it's part of the content, so it shouldn't be active)

7 comments:

Ralph said...

I just tried it in the Android browser on a Nexus One running Android 2.2, and I'm sorry to say it doesn't work.

Frankly, I'm very disappointed with the Android browser. For example, both anchors and text inputs become nonfunctional when contained in elements subject to CSS scaling transformations, at least in many cases. I'd hoped contenteditable divs might be a workable substitute for text inputs, but no go.

I expect better from Google. If they're serious about web applications being the future on portable devices, they need to furnish Android with a much better browser.

Alfonso said...

The title was a little rhetorical because as I said even if they said that the feature is available it doesn't really work as expected.

Anyway, I don't agree with your statements about the quality of the browser based on those elements.

CSS Transforms are something new, we could say that they are being tested for the first time and so it's no surprise that they have bugs, but you should find out if those bugs are present only in the Android browser or they behave in the same way in the webkit core and file the corresponding bug reports.

And trying to use contentEditable divs instead of text inputs is a bad idea in my point of view. With a text input you know that the user will put there only text, it's a normal form element, the user will have whatever facilities his OS/browser provides, but contentEditable is pure HTML, you have to take care about lots of other things and usually if you have problems with a text input now you will have all those problems plus the problems due to the support for editable html in the browser.

Anonymous said...

Yeah it doesn't work in android 2.2 with a droid.

You can force it to work by sliding out the droid keyboard, then click on the div and start typing.

But probably the only workaround now would be to create an in browser keyboard, or a canvas-based keyboard perhaps.

Unknown said...

Works for me on 2.2.1 using the default browser.

Unknown said...

And when using dolphin browser!

Alfonso said...

@Dave:
So when you touch the editable area above, you can see the caret?
And the keyboard opens up automatically?
And if you click on the link it doesn't navigate to google?

Wow, I've never seen that with the stock Android browser. Firefox does perform those tests correctly, but even with 2.3.3 the default browser still fails for me.

What's your phone?

Helio said...

For me, pressing the button returned True, but the field was not editable and the link was active.

Using HTC Desire with 2.3.3, Redux ROM.