Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9273 closed bug (notabug)

Dialog: the "appendTo" option should move the overlay if any

Reported by: paftek38 Owned by: paftek38
Priority: minor Milestone: none
Component: ui.dialog Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:

Description

Changing the "appendTo" option on the fly moves only the dialog, not its overlay.

Change History (10)

comment:1 Changed 6 years ago by Scott González

Owner: set to paftek38
Status: newpending

By on the fly, do you mean while open?

comment:2 Changed 6 years ago by paftek38

Status: pendingnew

Yes.

comment:3 Changed 6 years ago by Scott González

Status: newpending

Why are you changing the option while the dialog is open?

comment:4 in reply to:  3 ; Changed 6 years ago by paftek38

Status: pendingnew

Replying to scott.gonzalez:

Why are you changing the option while the dialog is open?


The widgets are automatically instanciated in my complex app. I need to move the dialog after that to solve a z-index issue. So I am doing something like :

$('#my_dialog').dialog('option', 'appendTo', target);

Problem: the overlay is not moved into "target".

Could the following solve the problem in _setOption()?

if ( key === "appendTo" ) {
    this.uiDialog.appendTo( this._appendTo() );
    if ( this.overlay) {
        this.overlay.appendTo( this._appendTo() );
    }
}

comment:5 in reply to:  4 ; Changed 6 years ago by Scott González

Status: newpending

Replying to paftek38:

The widgets are automatically instanciated in my complex app. I need to move the dialog after that to solve a z-index issue.

That doesn't explain why you're doing this while the dialog is open, instead of before opening the dialog. Why can't you set the option before opening the dialog?

Could the following solve the problem in _setOption()?

You'd need to do more than that. But if we change this, then we need to write a test for it. And I'd prefer not to do that because this is one of those things that you really shouldn't be doing.

comment:6 in reply to:  5 ; Changed 6 years ago by paftek38

Status: pendingnew

Replying to scott.gonzalez:

That doesn't explain why you're doing this while the dialog is open, instead of before opening the dialog. Why can't you set the option before opening the dialog?

I have my reasons to do that, I could probably do it differently but I think this is not the point.

Why should _setOption() allow to modify the appendTo option if it does half the job? If it is too hard to move the overlay while the dialog is open, we should probably prevent the appendTo option to be modified.

comment:7 in reply to:  6 ; Changed 6 years ago by Scott González

Status: newpending

Replying to paftek38:

I have my reasons to do that, I could probably do it differently but I think this is not the point.

It very much is the point. If you want something to work, you'll need to provide a valid use case.

Why should _setOption() allow to modify the appendTo option if it does half the job? If it is too hard to move the overlay while the dialog is open, we should probably prevent the appendTo option to be modified.

We're not going to write code to check if you're doing something that you shouldn't do. You need to provide a valid reason why you need to move the dialog while it's open if you want the behavior to change.

comment:8 in reply to:  7 Changed 6 years ago by paftek38

Status: pendingnew

Replying to scott.gonzalez:

We're not going to write code to check if you're doing something that you shouldn't do. You need to provide a valid reason why you need to move the dialog while it's open if you want the behavior to change.

You want to see it live? Here it is (with comments inside): http://jsfiddle.net/4KHmB/2/

comment:9 Changed 6 years ago by Scott González

Resolution: notabug
Status: newclosed

So you've built an app that doesn't do what you want. The best option is to fix your app to suit your needs, but you've said that's not an option... The next best option is to work around it in your code, since what you're working around is your own app... Just close the dialog, set the option, re-open the dialog: http://jsfiddle.net/4KHmB/3/

We're not going to change this behavior in jQuery UI, because there is no reasonable use case in which the option should change while already open.

I'll add a note to the docs to make this clear.

comment:10 in reply to:  9 Changed 6 years ago by paftek38

Replying to scott.gonzalez:

So you've built an app that doesn't do what you want. The best option is to fix your app to suit your needs, but you've said that's not an option...

Next time I would appreciate not to be treated like a fool.
You do not want to accept or understand the context of my problem ? Fine. You do not want to accept or understand that my app interacts with an external app and that I cannot have access to every step of the process ? Fine.

We're not going to change this behavior in jQuery UI, because there is no reasonable use case in which the option should change while already open.

If you want to be perfectly reasonable please prevent the _setOption('appendTo', ...) to do anything while the dialog is open. Because moving the dialog without moving its overlay is absurd IMHO.

Note: See TracTickets for help on using tickets.