Dialog closeOnExcape wrong behavior?

UI Components for JSF
Post Reply
FuinhaAzul
Posts: 12
Joined: 20 Feb 2012, 03:49

18 May 2022, 13:38

Hi there!!!

I updated an application from primefaces 6 to 10.0.12 and now when i stack two dialogs and hit ESC they close on wrong order and sometimes they close at the same time with just one ESC.

With this simple test we can see the strange behavior:

Code: Select all

<h:form>
		    <p:commandButton value="Modal" type="button" onclick="PF('dlg1').show();" />
			<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100" closeOnEscape="true">
				<h:outputText value="Dialog 2" />
			</p:dialog>
			<p:dialog header="Modal Dialog" widgetVar="dlg1" modal="true" height="100" closeOnEscape="true">
				<h:outputText value="Dialog 1" />
				<p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" />
			</p:dialog>
			
		</h:form>
Steps:

1 - Open dialog 1
2- Open dialog 2
3 - hit ESC
Behavior: The bottom dialog is closed first


PS: I saw the link https://github.com/primefaces/primefaces/issues/6677 that appear to show some changes on the dialog.


Thanks!!!!

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 May 2022, 17:59

it does it by z-Index matching now. So thta tells me your dialogs have the same zIndex when the new dialogs should be getting incremented to the next Zindex so every stacked dialog should be a higher zIndex than the previous one.

See this line:

Code: Select all

 if (e.which === keyCode.ESCAPE && $this.isVisible()) {
                    var active = parseInt($this.jq.css('z-index')) === parseInt($('.ui-dialog:visible').last().css('z-index'));
                    if (active) {
                        $this.hide();
                    }
                };
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests