Undo in Webapps

28 July 2011
21:44

Anyone who's built a web-based application (as opposed to “just” a website) will likely have learned that the Undo functionality that has been built in to desktop apps for decades is simply nonexistent on the Web. Browsers do have some native Undo support for changes in form elements, as well as for commands executed against contentEditable elements, but that's about it. If you have an application that responds to user interaction by, say, modifying the DOM, there is no good way to provide the user with a robust undo history.

What exactly does “robust” mean here?

  • Undo/redo can be triggered by the keyboard shortcuts defined by the system, which users are accustomed to using in desktop apps. Not just when the focus is on a specific element in the document, and when the webapp has been specifically written to intercept the common keyboard bindings on known systems (thereby conflicting with the native undo support).
  • Undo should also work when invoked not through keyboard shortcuts, but from the browser menu bar, context menu, or other means.
  • The undoable (or redoable) action should be given an descriptive label in the browser chrome. For example, in OS X the Undo menu item will often have a more specific name, such as “Undo Typing”, when it is available. (I assume something similar is available on other desktop UIs.)

We've all seen web applications (and in particular rich text editors) that provide custom undo/redo buttons, which are in no way related to the undo/redo history managed by the browser. It's really ugly, but currently there's just no better way. A number of web developers have been calling for a proper Undo API over the last years, but apparently there has not been enough demand to have such an API be included in the HTML5 family of specifications so far. That is unfortunate: if there's any part of web applications that makes them feel severely less powerful than desktop apps it may well be proper undo support (except maybe cross-application drag and drop, but that is already in HTML5, although via the rather cumbersome interface invented in Redmond).

So I'm really glad to see that some progress is being made here in the form of a proposal by Ryosuke Niwa. The draft specification looks rather promising to me at first glance, but I still need to review it in detail. I'm not sure whether it's a good idea to support more than one undo history per page in the form of undo scopes, as I was under the impression that you normally get just one undo history per document in desktop applications. This is probably intended to support applications where you can edit more than one “document” per page at a time, but I can already see it being abused to provide one undo history per instance of a rich text editor, which I think would be counter-intuitive.

Anyway, in the meantime I'd like to encourage everyone interested in webapp development to read the proposal and provide feedback. We really need proper undo support in web applications sooner rather than later.

Reactions

No comments or pings so far.