Skip to content

Commit 95ad045

Browse files
Merge pull request #13823 from SORMAS-Foundation/bug/13750-gdpr-modal
Fixes #13750: GDPR modal not in foreground.
2 parents 46ba946 + 6d3175d commit 95ad045

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/utils/VaadinUiUtil.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757

5858
public final class VaadinUiUtil {
5959

60+
public static final String FRONT_ELEMENT_STYLE_NAME = "front-element";
61+
6062
private VaadinUiUtil() {
6163
// Hide Utility Class Constructor
6264
}
@@ -71,6 +73,20 @@ public static Window createPopupWindow() {
7173
return window;
7274
}
7375

76+
/**
77+
* Enforces the popup to be in front of other modals.
78+
* Internally uses CSS's z-index to make it work.
79+
*
80+
* @return Window that will stay at front.
81+
*/
82+
public static Window createForegroundPopupWindow() {
83+
Window popupWindow = createPopupWindow();
84+
85+
popupWindow.setStyleName(FRONT_ELEMENT_STYLE_NAME);
86+
87+
return popupWindow;
88+
}
89+
7490
public static Window showSimplePopupWindow(String caption, String contentText) {
7591
return showSimplePopupWindow(caption, contentText, ContentMode.TEXT, null);
7692
}
@@ -640,7 +656,7 @@ public static void showWarningPopup(String message) {
640656

641657
public static void addGdprMessageOnClick(TextArea textArea) {
642658
AtomicBoolean gdprMessageTriggered = new AtomicBoolean(false);
643-
Window subWindowGdpR = VaadinUiUtil.createPopupWindow();
659+
Window subWindowGdpR = createForegroundPopupWindow();
644660

645661
textArea.addFocusListener(i -> {
646662
showGdprWindow(textArea, gdprMessageTriggered, subWindowGdpR);
@@ -655,12 +671,11 @@ public static void addGdprMessageOnClick(TextArea textArea) {
655671

656672
public static void addGdprMessageOnClick(RichTextArea richTextArea) {
657673
AtomicBoolean gdprMessageTriggered = new AtomicBoolean(false);
658-
Window subWindowGdpR = VaadinUiUtil.createPopupWindow();
674+
Window subWindowGdpR = VaadinUiUtil.createForegroundPopupWindow();
659675

660676
richTextArea.addValueChangeListener(event -> {
661677
if (!gdprMessageTriggered.get()) {
662678
showGdprWindow(richTextArea, gdprMessageTriggered, subWindowGdpR);
663-
subWindowGdpR.focus();
664679
gdprMessageTriggered.set(true);
665680
}
666681
});
@@ -696,6 +711,7 @@ private static void showGdprWindow(AbstractField<?> textArea, AtomicBoolean gdpr
696711
buttonLayout.setComponentAlignment(buttonGdpr, Alignment.BOTTOM_RIGHT);
697712
buttonLayout.setExpandRatio(buttonGdpr, 0);
698713
UI.getCurrent().addWindow(subWindowGdpR);
714+
subWindowGdpR.focus();
699715
}
700716
}
701717
}

sormas-ui/src/main/webapp/VAADIN/themes/sormas/global.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,8 @@
534534
.underline {
535535
text-decoration: underline;
536536
}
537+
538+
.front-element {
539+
z-index: 99999 !important;
540+
}
537541
}

0 commit comments

Comments
 (0)