Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.vaadin.flow.component.ModalityMode;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonTester;
import com.vaadin.flow.router.RouteConfiguration;
Expand Down Expand Up @@ -56,7 +57,17 @@ void programmaticallyClose_dialogIsDetached() {
}

@Test
void modalDialog_blocksUIComponents() {
void modalDialog_visual_doNotBlockUIComponents() {
view.dialog.setModality(ModalityMode.VISUAL);
dialog_.open();
ButtonTester<Button> button_ = test(view.button);
Assertions.assertTrue(button_.isUsable(),
"Default VISUAL modal dialog should not block button");
}

@Test
void modalDialog_strict_blocksUIComponents() {
view.dialog.setModality(ModalityMode.STRICT);
dialog_.open();
ButtonTester<Button> button_ = test(view.button);
Assertions.assertFalse(button_.isUsable(),
Expand All @@ -70,7 +81,7 @@ void modalDialog_blocksUIComponents() {

@Test
void nonModalDialog_UIComponentsUsable() {
view.dialog.setModal(false);
view.dialog.setModality(ModalityMode.MODELESS);
dialog_.open();
ButtonTester<Button> button_ = test(view.button);
Assertions.assertTrue(button_.isUsable(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package com.vaadin.testbench.unit.mocks

import com.vaadin.flow.component.Component
import com.vaadin.flow.component.ComponentEventListener
import com.vaadin.flow.component.ModalityMode
import com.vaadin.flow.component.UI
import com.vaadin.flow.shared.Registration
import java.util.concurrent.atomic.AtomicReference
Expand All @@ -26,9 +27,9 @@ import com.vaadin.testbench.unit.internal.simulateClosedEvent
*/
open class MockedUI : UI() {

override fun setChildComponentModal(childComponent: Component?, modal: Boolean) {
super.setChildComponentModal(childComponent, modal)
if (modal) {
override fun setChildComponentModal(childComponent: Component?, mode: ModalityMode) {
super.setChildComponentModal(childComponent, mode)
if (mode != ModalityMode.MODELESS) {
val registrationCombination: AtomicReference<Registration?> = AtomicReference<Registration?>()
registrationCombination.set(childComponent?.addDetachListener(ComponentEventListener {
roundTrip()
Expand Down