popup now all can be dismissed by clicking outside the window and have grey background

This commit is contained in:
Olivier Gagnon
2021-06-18 17:12:51 -04:00
parent 99263309ba
commit 5803ddc613
4 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -33,12 +33,17 @@ export function createPopup<T>(id: string, rootComponent: (props: T) => React.Re
let container = document.getElementById(id);
if (container == null) {
function onClick(this: HTMLElement, event: MouseEvent): any {
//console.log(this.id);
if(!event.srcElement) return;
if(!(event.srcElement instanceof HTMLElement)) return;
const clickedId = (event.srcElement as HTMLElement).id;
if(clickedId !== id) return;
removePopup(id);
}
container = createElement("div", {
class: "popup-box-container",
display: "flex",
id: id,
backgroundColor: 'rgba(0,0,0,0.5)',
clickListener: onClick,
});