Merge pull request #4425 from node-red/4418-fix-empty-status-background

Hide node status background when there is no status to show
This commit is contained in:
Nick O'Leary 2023-11-07 17:26:00 +00:00 committed by GitHub
commit 3f4d96f4cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4187,7 +4187,7 @@ RED.view = (function() {
nodeEl.__statusGroup__.style.display = "none"; nodeEl.__statusGroup__.style.display = "none";
} else { } else {
nodeEl.__statusGroup__.style.display = "inline"; nodeEl.__statusGroup__.style.display = "inline";
let backgroundWidth = 12 let backgroundWidth = 15
var fill = status_colours[d.status.fill]; // Only allow our colours for now var fill = status_colours[d.status.fill]; // Only allow our colours for now
if (d.status.shape == null && fill == null) { if (d.status.shape == null && fill == null) {
backgroundWidth = 0 backgroundWidth = 0
@ -4207,7 +4207,11 @@ RED.view = (function() {
nodeEl.__statusLabel__.textContent = ""; nodeEl.__statusLabel__.textContent = "";
} }
const textSize = nodeEl.__statusLabel__.getBBox() const textSize = nodeEl.__statusLabel__.getBBox()
nodeEl.__statusBackground__.setAttribute('width', backgroundWidth + textSize.width + 6) backgroundWidth += textSize.width
if (backgroundWidth > 0 && textSize.width > 0) {
backgroundWidth += 6
}
nodeEl.__statusBackground__.setAttribute('width', backgroundWidth)
} }
delete d.dirtyStatus; delete d.dirtyStatus;
} }
@ -4619,8 +4623,8 @@ RED.view = (function() {
statusBackground.setAttribute("y",-1); statusBackground.setAttribute("y",-1);
statusBackground.setAttribute("width",200); statusBackground.setAttribute("width",200);
statusBackground.setAttribute("height",13); statusBackground.setAttribute("height",13);
statusBackground.setAttribute("rx",1); statusBackground.setAttribute("rx",2);
statusBackground.setAttribute("ry",1); statusBackground.setAttribute("ry",2);
statusEl.appendChild(statusBackground); statusEl.appendChild(statusBackground);
node[0][0].__statusBackground__ = statusBackground; node[0][0].__statusBackground__ = statusBackground;