Skip to content

Commit cec15af

Browse files
committed
deploy: cd657c3
1 parent 332f5b0 commit cec15af

File tree

89 files changed

+564
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+564
-416
lines changed

LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function RemoteFunctions(config = {}) {
4040
// this will store the element that was clicked previously (before the new click)
4141
// we need this so that we can remove click styling from the previous element when a new element is clicked
4242
let previouslySelectedElement = null;
43+
let _selectedFromEditor = false;
4344
// Expose the currently selected element globally for external access
4445
window.__current_ph_lp_selected = null;
4546

@@ -496,6 +497,13 @@ function RemoteFunctions(config = {}) {
496497
}
497498

498499
this.elements = [];
500+
// Reset the cached selector so that redraw() uses the elements
501+
// array instead of re-querying the DOM with a stale selector.
502+
// Without this, a selector like [data-brackets-id='3'] persists
503+
// after the element is replaced (e.g. tag name change assigns a
504+
// new ID), causing redraw() to find zero matches and release
505+
// all overlays — making the highlight vanish.
506+
this.selector = "";
499507
},
500508

501509
redraw: function () {
@@ -550,8 +558,8 @@ function RemoteFunctions(config = {}) {
550558
}
551559

552560
const element = _lastHoverTarget;
553-
// Show hover overlay + hover box only for non-selected elements
554-
if (element && element !== previouslySelectedElement) {
561+
562+
if (element && (element !== previouslySelectedElement || _selectedFromEditor)) {
555563
_hoverHighlight.add(element);
556564
if (hoverBoxHandler) {
557565
hoverBoxHandler.showHoverBox(element);
@@ -642,6 +650,20 @@ function RemoteFunctions(config = {}) {
642650
* UI like control box, spacing handles, or measurements.
643651
*/
644652
function selectElement(element, fromEditor) {
653+
// When a cursor-based highlight re-selects the already-selected element,
654+
// just refresh the highlight overlay without dismissing existing UI panels
655+
// (control box, editor box, element-info). This prevents cursor activity
656+
// after a source edit (e.g., tag name change) from tearing down the
657+
// element properties panel and losing its state.
658+
if (fromEditor && element === previouslySelectedElement) {
659+
if (!_clickHighlight) {
660+
_clickHighlight = new Highlight();
661+
}
662+
_clickHighlight.clear();
663+
_clickHighlight.add(element);
664+
return;
665+
}
666+
645667
dismissUIAndCleanupState();
646668
// this should also be there when users are in highlight mode
647669
scrollElementToViewPort(element);
@@ -680,6 +702,7 @@ function RemoteFunctions(config = {}) {
680702
_clickHighlight.add(element);
681703

682704
previouslySelectedElement = element;
705+
_selectedFromEditor = fromEditor || false;
683706
window.__current_ph_lp_selected = element;
684707
}
685708

@@ -1315,6 +1338,19 @@ function RemoteFunctions(config = {}) {
13151338
}
13161339
previouslySelectedElement = freshElement;
13171340
window.__current_ph_lp_selected = freshElement;
1341+
// After element replacement (e.g., tag name change), the old
1342+
// DOM node is gone. Patch the element reference on any
1343+
// existing UI boxes so that position() doesn't bail on a
1344+
// disconnected node and future syncs resolve correctly.
1345+
// We update references directly rather than calling
1346+
// handler.updateContent() to avoid side-effects like
1347+
// re-creating a dismissed control box.
1348+
if (SHARED_STATE._controlBox) {
1349+
SHARED_STATE._controlBox.element = freshElement;
1350+
}
1351+
if (SHARED_STATE._editorBox) {
1352+
SHARED_STATE._editorBox.element = freshElement;
1353+
}
13181354
redrawEverything();
13191355
}
13201356
}

LiveDevelopment/LivePreviewConstants.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LiveDevelopment/MultiBrowserImpl/documents/LiveDocument.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)