Skip to content

Commit c754d60

Browse files
authored
🎨 UI/UX: Notifications bell tapping (#5511)
1 parent 83a430d commit c754d60

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

services/static-webserver/client/source/class/osparc/notification/NotificationsButton.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ qx.Class.define("osparc.notification.NotificationsButton", {
4141
this.__notificationsContainer = new osparc.notification.NotificationsContainer();
4242
this.__notificationsContainer.exclude();
4343

44-
this.addListener("tap", () => this.__showNotifications(), this);
44+
this.addListener("tap", this.__buttonTapped, this);
4545
},
4646

4747
members: {
4848
__notificationsContainer: null,
49+
__tappedOut: null,
4950

5051
_createChildControlImpl: function(id) {
5152
let control;
@@ -102,16 +103,23 @@ qx.Class.define("osparc.notification.NotificationsButton", {
102103
});
103104
},
104105

106+
__buttonTapped: function() {
107+
if (this.__tappedOut) {
108+
this.__tappedOut = false;
109+
return;
110+
}
111+
this.__showNotifications();
112+
},
113+
105114
__showNotifications: function() {
106-
const that = this;
107115
const tapListener = event => {
108-
const notificationsContainer = this.__notificationsContainer;
109-
if (osparc.utils.Utils.isMouseOnElement(notificationsContainer, event)) {
110-
return;
116+
// I somehow can't stop the propagation of the event so workaround:
117+
// If the user tapped on the bell we don't want to show it again
118+
if (osparc.utils.Utils.isMouseOnElement(this, event)) {
119+
this.__tappedOut = true;
111120
}
112-
// eslint-disable-next-line no-underscore-dangle
113-
that.__hideNotifications();
114-
document.removeEventListener("mousedown", tapListener);
121+
this.__hideNotifications();
122+
document.removeEventListener("mousedown", tapListener, this);
115123
};
116124

117125
const bounds = this.getBounds();
@@ -127,7 +135,7 @@ qx.Class.define("osparc.notification.NotificationsButton", {
127135
this.__notificationsContainer.setPosition(bounds.left+bounds.width-2, bounds.top+bounds.height-2);
128136
this.__notificationsContainer.show();
129137

130-
document.addEventListener("mousedown", tapListener);
138+
document.addEventListener("mousedown", tapListener, this);
131139
},
132140

133141
__hideNotifications: function() {

0 commit comments

Comments
 (0)