Skip to content

Commit f03e0de

Browse files
committed
fix: outline not appearing when element selected via css selector
1 parent d9b65dc commit f03e0de

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,13 @@ function RemoteFunctions(config = {}) {
649649
_cssSelectorHighlightTimer = null;
650650
}
651651
if (_cssSelectorHighlight) {
652+
// Restore original outlines on highlighted elements
653+
_cssSelectorHighlight.elements.forEach(function (el) {
654+
if (el._originalCssSelectorOutline !== undefined) {
655+
el.style.outline = el._originalCssSelectorOutline;
656+
delete el._originalCssSelectorOutline;
657+
}
658+
});
652659
_cssSelectorHighlight.clear();
653660
_cssSelectorHighlight = null;
654661
}
@@ -667,6 +674,12 @@ function RemoteFunctions(config = {}) {
667674
LivePreviewView.isElementInspectable(nodes[i], true) &&
668675
nodes[i].nodeType === Node.ELEMENT_NODE) {
669676
_cssSelectorHighlight.add(nodes[i]);
677+
// Apply outline to all matching elements so they are visible
678+
// even when they have no margin/padding
679+
nodes[i]._originalCssSelectorOutline = nodes[i].style.outline;
680+
const isEditable = nodes[i].hasAttribute(GLOBALS.DATA_BRACKETS_ID_ATTR);
681+
const outlineColor = isEditable ? COLORS.outlineEditable : COLORS.outlineNonEditable;
682+
nodes[i].style.outline = `1px solid ${outlineColor}`;
670683
}
671684
}
672685
_cssSelectorHighlight.selector = rule;

0 commit comments

Comments
 (0)