Replying to [comment:20 rcollette]:
Can someone explain why auto focusing on the first link provides accessibility? I have a dialog whose content comes from a content management system. Having to explain to the users that they have to insert a dummy hidden link in their content to prevent the dialog from scrolling down through the content is not user friendly. Sure I can prepend the content retrieved from the CMS with a link as well but this seems kludgy.
It's not necessarily the first link, per the code itself it's actually...
Set focus to the first match:
1. First element inside the dialog matching [autofocus]
2. Tabbable element inside the content element
3. Tabbable element inside the buttonpane
4. The close button
5. The dialog itself
Screen readers will announce when focus changes. If focus does not change when a dialog is opened then screen reader users will not know that it happened.
There are easier ways to prevent the dialog from scrolling than including a hidden link, see http://jsbin.com/icuguz/12/edit. There's a ticket open to prevent the scrolling you're referring to: http://bugs.jqueryui.com/ticket/6006. We'd be happy to review a pull request.