diff --git a/vaadin-popover-flow-parent/vaadin-popover-flow/src/main/java/com/vaadin/flow/component/popover/Popover.java b/vaadin-popover-flow-parent/vaadin-popover-flow/src/main/java/com/vaadin/flow/component/popover/Popover.java index 48a1568bbbc..63630b42169 100644 --- a/vaadin-popover-flow-parent/vaadin-popover-flow/src/main/java/com/vaadin/flow/component/popover/Popover.java +++ b/vaadin-popover-flow-parent/vaadin-popover-flow/src/main/java/com/vaadin/flow/component/popover/Popover.java @@ -166,6 +166,11 @@ public Registration addOpenedChangeListener( * popover is modal, interacting with elements behind it will be prevented * until the popover is closed. *

+ * Setting the modal to {@code true} does not enable showing the backdrop + * (modality curtain) automatically. This should be done separately using + * {@link #setBackdropVisible(boolean)} or optionally passed as a second + * parameter using {@link #setModal(boolean, boolean)}. + *

* NOTE: this setting does not involve server-side modality, as the modal * popover is typically not used to prevent anything else from happening * while it's open. @@ -175,11 +180,35 @@ public Registration addOpenedChangeListener( * @param modal * {@code true} to enable popover to open as modal, {@code false} * otherwise. + * @see #setBackdropVisible(boolean) + * @see #setModal(boolean, boolean) */ public void setModal(boolean modal) { getElement().setProperty("modal", modal); } + /** + * Sets whether component should open modal or modeless popover and whether + * the component should show a backdrop (modality curtain) when opened. + *

+ * NOTE: this setting does not involve server-side modality, as the modal + * popover is typically not used to prevent anything else from happening + * while it's open. + *

+ * By default, the popover is non-modal and has no modality curtain. + * + * @param modal + * {@code true} to enable popover to open as modal, {@code false} + * otherwise. + * @param backdropVisible + * {@code true} to show the backdrop, {@code false} otherwise. + * @see #setBackdropVisible(boolean) + */ + public void setModal(boolean modal, boolean backdropVisible) { + setModal(modal); + setBackdropVisible(backdropVisible); + } + /** * Gets whether component is set as modal or modeless popover. By default, * the popover is non-modal. diff --git a/vaadin-popover-flow-parent/vaadin-popover-flow/src/test/java/com/vaadin/flow/component/popover/PopoverTest.java b/vaadin-popover-flow-parent/vaadin-popover-flow/src/test/java/com/vaadin/flow/component/popover/PopoverTest.java index 031fae06f9d..ec46d31d221 100644 --- a/vaadin-popover-flow-parent/vaadin-popover-flow/src/test/java/com/vaadin/flow/component/popover/PopoverTest.java +++ b/vaadin-popover-flow-parent/vaadin-popover-flow/src/test/java/com/vaadin/flow/component/popover/PopoverTest.java @@ -264,6 +264,17 @@ public void setBackdropVisible_isBackdropVisible() { popover.getElement().getProperty("withBackdrop", false)); } + @Test + public void setModalAndBackdropVisible() { + popover.setModal(true, true); + Assert.assertTrue(popover.isModal()); + Assert.assertTrue(popover.isBackdropVisible()); + + popover.setModal(false, false); + Assert.assertFalse(popover.isModal()); + Assert.assertFalse(popover.isBackdropVisible()); + } + @Test public void setAutofocus_isAutofocus() { Assert.assertFalse(popover.isAutofocus());