Skip to content

Commit 33aba46

Browse files
fix: preserve overlays opened after forwarding to view (#7304) (#7308)
* fix: preserve overlays after forwarding to view * update OverlayAutoAddControllerTest * update existing ITs * add new ITs * run formatter * update confirm dialog ITs * update login overlay ITs * update notification ITs Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent a883c7c commit 33aba46

26 files changed

Lines changed: 493 additions & 86 deletions

File tree

vaadin-confirm-dialog-flow-parent/vaadin-confirm-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/confirmdialog/tests/OverlayForwardingSourcePage.java renamed to vaadin-confirm-dialog-flow-parent/vaadin-confirm-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/confirmdialog/tests/ConfirmDialogOpenedAfterForwardingSourcePage.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@
1515
*/
1616
package com.vaadin.flow.component.confirmdialog.tests;
1717

18-
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
18+
import com.vaadin.flow.component.html.Div;
1919
import com.vaadin.flow.router.BeforeEnterEvent;
2020
import com.vaadin.flow.router.BeforeEnterObserver;
2121
import com.vaadin.flow.router.Route;
2222

23-
@Route("vaadin-confirm-dialog/overlay-remains-in-dom-after-detach-view")
24-
public class OverlayForwardingSourcePage extends ConfirmDialog
23+
@Route("vaadin-confirm-dialog/confirm-dialog-opened-after-forwarding-source")
24+
public class ConfirmDialogOpenedAfterForwardingSourcePage extends Div
2525
implements BeforeEnterObserver {
2626

2727
@Override
2828
public void beforeEnter(BeforeEnterEvent event) {
29-
event.forwardTo(OverlayForwardingTargetPage.class);
30-
}
31-
32-
public OverlayForwardingSourcePage() {
33-
setOpened(true);
29+
event.forwardTo(ConfirmDialogOpenedAfterForwardingTargetPage.class);
3430
}
3531
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.confirmdialog.tests;
17+
18+
import com.vaadin.flow.component.Text;
19+
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
20+
import com.vaadin.flow.component.html.Div;
21+
import com.vaadin.flow.router.Route;
22+
23+
@Route("vaadin-confirm-dialog/confirm-dialog-opened-after-forwarding-target")
24+
public class ConfirmDialogOpenedAfterForwardingTargetPage extends Div {
25+
public ConfirmDialogOpenedAfterForwardingTargetPage() {
26+
setId("forwarded-view");
27+
add(new Text("Forwarded"));
28+
new ConfirmDialog().open();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.confirmdialog.tests;
17+
18+
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
19+
import com.vaadin.flow.component.html.Div;
20+
import com.vaadin.flow.router.BeforeEnterEvent;
21+
import com.vaadin.flow.router.BeforeEnterObserver;
22+
import com.vaadin.flow.router.Route;
23+
24+
@Route("vaadin-confirm-dialog/confirm-dialog-opened-before-forwarding-source")
25+
public class ConfirmDialogOpenedBeforeForwardingSourcePage extends Div
26+
implements BeforeEnterObserver {
27+
28+
public ConfirmDialogOpenedBeforeForwardingSourcePage() {
29+
new ConfirmDialog().open();
30+
}
31+
32+
@Override
33+
public void beforeEnter(BeforeEnterEvent event) {
34+
event.forwardTo(ConfirmDialogOpenedBeforeForwardingTargetPage.class);
35+
}
36+
}

vaadin-confirm-dialog-flow-parent/vaadin-confirm-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/confirmdialog/tests/OverlayForwardingTargetPage.java renamed to vaadin-confirm-dialog-flow-parent/vaadin-confirm-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/confirmdialog/tests/ConfirmDialogOpenedBeforeForwardingTargetPage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import com.vaadin.flow.component.html.Div;
2020
import com.vaadin.flow.router.Route;
2121

22-
@Route("vaadin-confirm-dialog/forwarding-target")
23-
public class OverlayForwardingTargetPage extends Div {
24-
public OverlayForwardingTargetPage() {
22+
@Route("vaadin-confirm-dialog/confirm-dialog-opened-before-forwarding-target")
23+
public class ConfirmDialogOpenedBeforeForwardingTargetPage extends Div {
24+
public ConfirmDialogOpenedBeforeForwardingTargetPage() {
2525
setId("forwarded-view");
2626
add(new Text("Forwarded"));
2727
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.confirmdialog.tests;
17+
18+
import org.junit.Assert;
19+
import org.junit.Before;
20+
import org.junit.Test;
21+
import org.openqa.selenium.By;
22+
23+
import com.vaadin.flow.testutil.TestPath;
24+
import com.vaadin.tests.AbstractComponentIT;
25+
26+
@TestPath("vaadin-confirm-dialog/confirm-dialog-opened-after-forwarding-source")
27+
public class ConfirmDialogOpenedAfterForwardingIT extends AbstractComponentIT {
28+
29+
@Before
30+
public void init() {
31+
open();
32+
}
33+
34+
@Test
35+
public void openDialog_forward_dialogPresent() {
36+
waitForElementPresent(By.id("forwarded-view"));
37+
Assert.assertTrue(
38+
isElementPresent(By.tagName("vaadin-confirm-dialog-overlay")));
39+
}
40+
}

vaadin-confirm-dialog-flow-parent/vaadin-confirm-dialog-flow-integration-tests/src/test/java/com/vaadin/flow/component/confirmdialog/tests/OverlayForwardingIT.java renamed to vaadin-confirm-dialog-flow-parent/vaadin-confirm-dialog-flow-integration-tests/src/test/java/com/vaadin/flow/component/confirmdialog/tests/ConfirmDialogOpenedBeforeForwardingIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
import com.vaadin.flow.testutil.TestPath;
2424
import com.vaadin.tests.AbstractComponentIT;
2525

26-
@TestPath("vaadin-confirm-dialog/overlay-remains-in-dom-after-detach-view")
27-
public class OverlayForwardingIT extends AbstractComponentIT {
26+
@TestPath("vaadin-confirm-dialog/confirm-dialog-opened-before-forwarding-source")
27+
public class ConfirmDialogOpenedBeforeForwardingIT extends AbstractComponentIT {
2828

2929
@Before
3030
public void init() {
3131
open();
3232
}
3333

3434
@Test
35-
public void forwardPageInBeforeEnter_newPageDoesNotContainVaadinConfirmDialogOverlay() {
35+
public void openDialog_forward_noDialogPresent() {
3636
waitForElementPresent(By.id("forwarded-view"));
3737
Assert.assertFalse(
3838
isElementPresent(By.tagName("vaadin-confirm-dialog-overlay")));

vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/OverlayForwardingSourcePage.java renamed to vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/DialogOpenedAfterForwardingSourcePage.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@
1515
*/
1616
package com.vaadin.flow.component.dialog.tests;
1717

18-
import com.vaadin.flow.component.dialog.Dialog;
18+
import com.vaadin.flow.component.html.Div;
1919
import com.vaadin.flow.router.BeforeEnterEvent;
2020
import com.vaadin.flow.router.BeforeEnterObserver;
2121
import com.vaadin.flow.router.Route;
2222

23-
@Route("vaadin-dialog/overlay-remains-in-dom-after-detach-view")
24-
public class OverlayForwardingSourcePage extends Dialog
23+
@Route("vaadin-dialog/dialog-opened-after-forwarding-source")
24+
public class DialogOpenedAfterForwardingSourcePage extends Div
2525
implements BeforeEnterObserver {
2626

2727
@Override
2828
public void beforeEnter(BeforeEnterEvent event) {
29-
event.forwardTo(OverlayForwardingTargetPage.class);
30-
}
31-
32-
public OverlayForwardingSourcePage() {
33-
setOpened(true);
29+
event.forwardTo(DialogOpenedAfterForwardingTargetPage.class);
3430
}
3531
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.dialog.tests;
17+
18+
import com.vaadin.flow.component.Text;
19+
import com.vaadin.flow.component.dialog.Dialog;
20+
import com.vaadin.flow.component.html.Div;
21+
import com.vaadin.flow.router.Route;
22+
23+
@Route("vaadin-dialog/dialog-opened-after-forwarding-target")
24+
public class DialogOpenedAfterForwardingTargetPage extends Div {
25+
public DialogOpenedAfterForwardingTargetPage() {
26+
setId("forwarded-view");
27+
add(new Text("Forwarded"));
28+
new Dialog().open();
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.dialog.tests;
17+
18+
import com.vaadin.flow.component.dialog.Dialog;
19+
import com.vaadin.flow.component.html.Div;
20+
import com.vaadin.flow.router.BeforeEnterEvent;
21+
import com.vaadin.flow.router.BeforeEnterObserver;
22+
import com.vaadin.flow.router.Route;
23+
24+
@Route("vaadin-dialog/dialog-opened-before-forwarding-source")
25+
public class DialogOpenedBeforeForwardingSourcePage extends Div
26+
implements BeforeEnterObserver {
27+
28+
public DialogOpenedBeforeForwardingSourcePage() {
29+
new Dialog().open();
30+
}
31+
32+
@Override
33+
public void beforeEnter(BeforeEnterEvent event) {
34+
event.forwardTo(DialogOpenedBeforeForwardingTargetPage.class);
35+
}
36+
}

vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/OverlayForwardingTargetPage.java renamed to vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/DialogOpenedBeforeForwardingTargetPage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import com.vaadin.flow.component.html.Div;
2020
import com.vaadin.flow.router.Route;
2121

22-
@Route("vaadin-dialog/forwarding-target")
23-
public class OverlayForwardingTargetPage extends Div {
24-
public OverlayForwardingTargetPage() {
22+
@Route("vaadin-dialog/dialog-opened-before-forwarding-target")
23+
public class DialogOpenedBeforeForwardingTargetPage extends Div {
24+
public DialogOpenedBeforeForwardingTargetPage() {
2525
setId("forwarded-view");
2626
add(new Text("Forwarded"));
2727
}

0 commit comments

Comments
 (0)