@@ -2205,10 +2205,26 @@ function RemoteFunctions(config = {}) {
22052205
22062206 // helper function to clear element background highlighting
22072207 function clearElementBackground ( element ) {
2208+ // make sure that the feature is enabled and also the element has the attribute 'data-brackets-id'
2209+ if (
2210+ ! config . isLPEditFeaturesActive ||
2211+ ! element . hasAttribute ( "data-brackets-id" ) ||
2212+ element . tagName === "BODY" ||
2213+ element . tagName === "HTML" ||
2214+ _isInsideHeadTag ( element )
2215+ ) {
2216+ return ;
2217+ }
2218+
22082219 if ( element . _originalBackgroundColor !== undefined ) {
22092220 element . style . backgroundColor = element . _originalBackgroundColor ;
22102221 } else {
2211- element . style . backgroundColor = "" ;
2222+ // only clear background if it's currently a highlight color, not if it's an original user style
2223+ const currentBg = element . style . backgroundColor ;
2224+ if ( currentBg === "rgba(0, 162, 255, 0.2)" || currentBg . includes ( "rgba(0, 162, 255" ) ) {
2225+ element . style . backgroundColor = "" ;
2226+ }
2227+ // if it's some other color, we just leave it as is - it's likely a user-defined style
22122228 }
22132229 delete element . _originalBackgroundColor ;
22142230 }
@@ -2308,15 +2324,14 @@ function RemoteFunctions(config = {}) {
23082324 element . _originalOutline = element . style . outline ;
23092325 element . style . outline = "1px solid #4285F4" ;
23102326
2311- // Add highlight for click mode
2312- if ( getHighlightMode ( ) === "click" ) {
2327+ if ( element . _originalBackgroundColor === undefined ) {
23132328 element . _originalBackgroundColor = element . style . backgroundColor ;
2314- element . style . backgroundColor = "rgba(0, 162, 255, 0.2)" ;
2329+ }
2330+ element . style . backgroundColor = "rgba(0, 162, 255, 0.2)" ;
23152331
2316- if ( _hoverHighlight ) {
2317- _hoverHighlight . clear ( ) ;
2318- _hoverHighlight . add ( element , true , false ) ; // false means no auto-scroll
2319- }
2332+ if ( _hoverHighlight ) {
2333+ _hoverHighlight . clear ( ) ;
2334+ _hoverHighlight . add ( element , true , false ) ; // false means no auto-scroll
23202335 }
23212336
23222337 previouslyClickedElement = element ;
0 commit comments