Skip to content

Commit edcddb0

Browse files
committed
fix: highlight not working expected at all cases
1 parent 37e1a47 commit edcddb0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,11 @@ function RemoteFunctions(config = {}) {
757757
});
758758
}
759759

760-
// call the selectElement as selectElement handles all the highlighting/boxes and all UI related stuff
761-
selectElement(element);
760+
// we call the select element function only when the element is not editable (JS generated content)
761+
// because for editable elements, highlightRule function already calls selectElement internally
762+
if (!LivePreviewView.isElementEditable(element)) {
763+
selectElement(element);
764+
}
762765
brieflyDisableHoverListeners();
763766
}
764767

@@ -800,13 +803,10 @@ function RemoteFunctions(config = {}) {
800803
}
801804

802805
// select the first valid highlighted element
803-
var foundValidElement = false;
806+
let foundValidElement = false;
804807
for (i = 0; i < nodes.length; i++) {
805808
if(LivePreviewView.isElementInspectable(nodes[i], true) && nodes[i].tagName !== "BR") {
806-
// only call selectElement if it's a different element to avoid unnecessary box recreation
807-
if (previouslyClickedElement !== nodes[i]) {
808-
selectElement(nodes[i]);
809-
}
809+
selectElement(nodes[i]);
810810
foundValidElement = true;
811811
break;
812812
}
@@ -1201,7 +1201,10 @@ function RemoteFunctions(config = {}) {
12011201
previouslyClickedElement.style.outline = "";
12021202
}
12031203
delete previouslyClickedElement._originalOutline;
1204+
previouslyClickedElement = null;
1205+
}
12041206

1207+
if (config.mode === 'edit') {
12051208
hideHighlight();
12061209

12071210
// Notify handlers about cleanup
@@ -1210,8 +1213,6 @@ function RemoteFunctions(config = {}) {
12101213
handler.onElementCleanup();
12111214
}
12121215
});
1213-
1214-
previouslyClickedElement = null;
12151216
}
12161217
}
12171218

0 commit comments

Comments
 (0)