forked from mbk-lab/rui_orig
2
0
Fork 0

Bug fixing

This commit is contained in:
anoshenko 2023-05-07 20:58:51 +03:00
parent b15305d727
commit 1cf0ee0bae
6 changed files with 14 additions and 8 deletions

View File

@ -149,7 +149,6 @@ func (app *wasmApp) init(params AppParams) {
div = document.Call("createElement", "div")
div.Set("className", "ruiPopupLayer")
div.Set("id", "ruiPopupLayer")
div.Set("onclick", "clickOutsidePopup(event)")
div.Set("style", "visibility: hidden;")
body.Call("appendChild", div)

View File

@ -1253,11 +1253,6 @@ function loadInlineImage(url, content) {
img.src = content;
}
function clickOutsidePopup(e) {
sendMessage("clickOutsidePopup{session=" + sessionID + "}")
e.stopPropagation();
}
function clickClosePopup(element, e) {
var popupId = element.getAttribute("data-popupId");
sendMessage("clickClosePopup{session=" + sessionID + ",id=" + popupId + "}")
@ -2072,6 +2067,14 @@ function mouseLeaveEvent(element, event) {
sendMessage("mouse-leave{session=" + sessionID + ",id=" + element.id + mouseEventData(element, event) + "}");
}
function hideTooltip() {
const layer = document.getElementById("ruiTooltipLayer");
if (layer) {
layer.style.opacity = 0;
layer.style.visibility = "hidden";
}
}
function stopEventPropagation(element, event) {
event.stopPropagation();
}

View File

@ -75,7 +75,7 @@ func getStartPage(buffer *strings.Builder, params AppParams, addScripts string)
</head>
<body>
<div class="ruiRoot" id="ruiRootView"></div>
<div class="ruiPopupLayer" id="ruiPopupLayer" style="visibility: hidden; isolation: isolate;" onclick="clickOutsidePopup(event)"></div>
<div class="ruiPopupLayer" id="ruiPopupLayer" style="visibility: hidden; isolation: isolate;"></div>
<div class="ruiTooltipLayer" id="ruiTooltipLayer" style="visibility: hidden; opacity: 0;">
<div id="ruiTooltipText" class="ruiTooltipText"></div>
<div id="ruiTooltipTopArrow" class="ruiTooltipTopArrow"></div>

View File

@ -652,7 +652,7 @@ func (session *sessionData) handleEvent(command string, data DataObject) {
if view := session.viewByHTMLID(viewID); view != nil {
view.handleCommand(view, command, data)
}
} else if command != "clickOutsidePopup" {
} else {
ErrorLog(`"id" property not found. Event: ` + command)
}
}

View File

@ -27,6 +27,8 @@ func updateInnerHTML(htmlID string, session Session) {
view = session.viewByHTMLID(htmlID)
}
if view != nil {
session.callFunc("hideTooltip")
script := allocStringBuilder()
defer freeStringBuilder(script)

View File

@ -412,10 +412,12 @@ func viewPropertyChanged(view *viewData, tag string) {
case Invisible:
session.updateCSSProperty(htmlID, Visibility, "hidden")
session.updateCSSProperty(htmlID, "display", "")
session.callFunc("hideTooltip")
case Gone:
session.updateCSSProperty(htmlID, Visibility, "hidden")
session.updateCSSProperty(htmlID, "display", "none")
session.callFunc("hideTooltip")
default:
session.updateCSSProperty(htmlID, Visibility, "visible")