Had the same problem and thanks to you mentioning that the real problem was related to CSS I found the issue:
Having position:relative
instead of position:absolute
in your .ui-dialog
CSS rule makes the dialog and width:'auto'
behave strangely.
.ui-dialog { position: absolute;}