@@ -441,13 +441,19 @@ function RemoteFunctions(config = {}) {
441441 _hoverHighlight . elements . forEach ( clearElementHoverHighlight ) ;
442442 _hoverHighlight . clear ( ) ;
443443
444- // Store original outline to restore on hover out, then apply a border
445- element . _originalHoverOutline = element . style . outline ;
446- const isEditable = element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ;
447- const outlineColor = isEditable ? COLORS . outlineEditable : COLORS . outlineNonEditable ;
448- element . style . outline = `1px solid ${ outlineColor } ` ;
444+ // Skip hover outline and overlay for the currently click-selected element.
445+ // It already has its own outline and overlay from the click/selection flow.
446+ // Adding hover state on top would corrupt _originalHoverOutline (it would capture
447+ // the click outline instead of the true original) and stack duplicate overlays.
448+ if ( element !== previouslySelectedElement ) {
449+ // Store original outline to restore on hover out, then apply a border
450+ element . _originalHoverOutline = element . style . outline ;
451+ const isEditable = element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ;
452+ const outlineColor = isEditable ? COLORS . outlineEditable : COLORS . outlineNonEditable ;
453+ element . style . outline = `1px solid ${ outlineColor } ` ;
449454
450- _hoverHighlight . add ( element ) ;
455+ _hoverHighlight . add ( element ) ;
456+ }
451457
452458 // create the info box for the hovered element
453459 const infoBoxHandler = LivePreviewView . getToolHandler ( "InfoBox" ) ;
@@ -1151,6 +1157,10 @@ function RemoteFunctions(config = {}) {
11511157 */
11521158 function cleanupPreviousElementState ( ) {
11531159 if ( previouslySelectedElement ) {
1160+ // Safety net: clear any stale hover outline tracking before hideHighlight runs.
1161+ // This prevents clearElementHoverHighlight from re-applying a captured click outline
1162+ // in edge cases where _originalHoverOutline was set on the selected element.
1163+ delete previouslySelectedElement . _originalHoverOutline ;
11541164 if ( previouslySelectedElement . _originalOutline !== undefined ) {
11551165 previouslySelectedElement . style . outline = previouslySelectedElement . _originalOutline ;
11561166 } else {
0 commit comments