@@ -764,8 +764,11 @@ function RemoteFunctions(config = {}) {
764764 } ) ;
765765 }
766766
767- // call the selectElement as selectElement handles all the highlighting/boxes and all UI related stuff
768- selectElement ( element ) ;
767+ // we call the select element function only when the element is not editable (JS generated content)
768+ // because for editable elements, highlightRule function already calls selectElement internally
769+ if ( ! LivePreviewView . isElementEditable ( element ) ) {
770+ selectElement ( element ) ;
771+ }
769772 brieflyDisableHoverListeners ( ) ;
770773 }
771774
@@ -807,13 +810,10 @@ function RemoteFunctions(config = {}) {
807810 }
808811
809812 // select the first valid highlighted element
810- var foundValidElement = false ;
813+ let foundValidElement = false ;
811814 for ( i = 0 ; i < nodes . length ; i ++ ) {
812815 if ( LivePreviewView . isElementInspectable ( nodes [ i ] , true ) && nodes [ i ] . tagName !== "BR" ) {
813- // only call selectElement if it's a different element to avoid unnecessary box recreation
814- if ( previouslyClickedElement !== nodes [ i ] ) {
815- selectElement ( nodes [ i ] ) ;
816- }
816+ selectElement ( nodes [ i ] ) ;
817817 foundValidElement = true ;
818818 break ;
819819 }
@@ -1208,7 +1208,10 @@ function RemoteFunctions(config = {}) {
12081208 previouslyClickedElement . style . outline = "" ;
12091209 }
12101210 delete previouslyClickedElement . _originalOutline ;
1211+ previouslyClickedElement = null ;
1212+ }
12111213
1214+ if ( config . mode === 'edit' ) {
12121215 hideHighlight ( ) ;
12131216
12141217 // Notify handlers about cleanup
@@ -1217,8 +1220,6 @@ function RemoteFunctions(config = {}) {
12171220 handler . onElementCleanup ( ) ;
12181221 }
12191222 } ) ;
1220-
1221- previouslyClickedElement = null ;
12221223 }
12231224 }
12241225
0 commit comments