It's not a bug. With a
show option of
fade (or anything) the display of the dialog becomes asynchronous and happens after the rest of your code runs. So you request the dialog to open, you set the focus to
password, the dialog opens, and sets the focus to the first field. You need to add a delay to the focus call, since there isn't a handy event after the dialog is fully shown. Something like this (adjust the timing as necessary):
- $('#dialog-form').dialog({
- autoOpen: false,
- title: 'Title',
- height: 300,
- width: 350,
- modal: true,
- show: 'fade',
- hide: 'fade',
- open: function() {
- setTimeout(function() {
- $('#password').focus();
- }, 420); // After 420 ms
- },
- close: function() {
- $(this).dialog('close');
- }
- });
-
- $('#showDialog-button').on('click', function() {
- $('#dialog-form').dialog('open');
- });
You could raise a ticket suggesting the team add a post-open callback that you could use for this requirement.