Skip to content

Commit cfcbdfb

Browse files
committed
fix: element highlighting disappears when setting is modified
1 parent f3aa047 commit cfcbdfb

2 files changed

Lines changed: 58 additions & 23 deletions

File tree

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ function RemoteFunctions(config = {}) {
455455
_hoverHighlight.add(element);
456456
}
457457

458-
// create the info box for the hovered element
459-
const infoBoxHandler = LivePreviewView.getToolHandler("InfoBox");
460-
if (infoBoxHandler) {
461-
infoBoxHandler.dismiss();
462-
infoBoxHandler.createInfoBox(element);
463-
}
458+
// commented out for unified box redesign
459+
// const infoBoxHandler = LivePreviewView.getToolHandler("InfoBox");
460+
// if (infoBoxHandler) {
461+
// infoBoxHandler.dismiss();
462+
// infoBoxHandler.createInfoBox(element);
463+
// }
464464
}
465465
}
466466

@@ -772,23 +772,24 @@ function RemoteFunctions(config = {}) {
772772

773773
// recreate UI boxes so that they are placed properly
774774
function redrawUIBoxes() {
775-
if (SHARED_STATE._toolBox) {
776-
const element = SHARED_STATE._toolBox.element;
777-
const toolBoxHandler = LivePreviewView.getToolHandler("ToolBox");
778-
if (toolBoxHandler) {
779-
toolBoxHandler.dismiss();
780-
toolBoxHandler.createToolBox(element);
781-
}
782-
}
783-
784-
if (SHARED_STATE._infoBox) {
785-
const element = SHARED_STATE._infoBox.element;
786-
const infoBoxHandler = LivePreviewView.getToolHandler("InfoBox");
787-
if (infoBoxHandler) {
788-
infoBoxHandler.dismiss();
789-
infoBoxHandler.createInfoBox(element);
790-
}
791-
}
775+
// commented out for unified box redesign
776+
// if (SHARED_STATE._toolBox) {
777+
// const element = SHARED_STATE._toolBox.element;
778+
// const toolBoxHandler = LivePreviewView.getToolHandler("ToolBox");
779+
// if (toolBoxHandler) {
780+
// toolBoxHandler.dismiss();
781+
// toolBoxHandler.createToolBox(element);
782+
// }
783+
// }
784+
785+
// if (SHARED_STATE._infoBox) {
786+
// const element = SHARED_STATE._infoBox.element;
787+
// const infoBoxHandler = LivePreviewView.getToolHandler("InfoBox");
788+
// if (infoBoxHandler) {
789+
// infoBoxHandler.dismiss();
790+
// infoBoxHandler.createInfoBox(element);
791+
// }
792+
// }
792793
}
793794

794795
// redraw active highlights
@@ -1140,7 +1141,25 @@ function RemoteFunctions(config = {}) {
11401141
_handleConfigurationChange();
11411142
}
11421143

1144+
// Preserve the currently selected element across re-registration
1145+
// so that toggling options (e.g. show measurements, show spacing handles)
1146+
// doesn't clear the element highlighting.
1147+
const selectedBeforeReregister = previouslySelectedElement;
11431148
registerHandlers();
1149+
if (!isModeChanged && !highlightModeChanged && selectedBeforeReregister
1150+
&& config.mode === 'edit') {
1151+
// Restore the click highlight for the previously selected element
1152+
if (!_clickHighlight) {
1153+
_clickHighlight = new Highlight(true);
1154+
}
1155+
_clickHighlight.add(selectedBeforeReregister);
1156+
previouslySelectedElement = selectedBeforeReregister;
1157+
window.__current_ph_lp_selected = selectedBeforeReregister;
1158+
// Restore the outline
1159+
const isEditable = selectedBeforeReregister.hasAttribute(GLOBALS.DATA_BRACKETS_ID_ATTR);
1160+
const outlineColor = isEditable ? COLORS.outlineEditable : COLORS.outlineNonEditable;
1161+
selectedBeforeReregister.style.outline = `1px solid ${outlineColor}`;
1162+
}
11441163
return JSON.stringify(config);
11451164
}
11461165

src/nls/root/strings.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,22 @@ define({
291291
"LIVE_DEV_STYLES_QS_BOX_SHADOW": "Box Shadow",
292292
"LIVE_DEV_STYLES_QS_SELECTOR": "Selector",
293293
"LIVE_DEV_STYLES_QS_ELEMENT_STYLE": "element.style",
294+
"LIVE_DEV_STYLES_QS_FLEX_WRAP": "Wrap",
295+
"LIVE_DEV_STYLES_QS_FLEX_GROW": "Grow",
296+
"LIVE_DEV_STYLES_QS_FLEX_SHRINK": "Shrink",
297+
"LIVE_DEV_STYLES_QS_ORDER": "Order",
298+
"LIVE_DEV_STYLES_QS_ALIGN_SELF": "Align Self",
299+
"LIVE_DEV_STYLES_QS_JUSTIFY_SELF": "Justify Self",
300+
"LIVE_DEV_STYLES_QS_GRID_TEMPLATE_COLS": "Columns",
301+
"LIVE_DEV_STYLES_QS_GRID_TEMPLATE_ROWS": "Rows",
302+
"LIVE_DEV_STYLES_QS_GRID_COLUMN": "Column",
303+
"LIVE_DEV_STYLES_QS_GRID_ROW": "Row",
304+
"LIVE_DEV_STYLES_QS_OBJECT_FIT": "Object Fit",
305+
"LIVE_DEV_STYLES_QS_FLEX_BASIS": "Basis",
306+
"LIVE_DEV_STYLES_QS_TOP": "Top",
307+
"LIVE_DEV_STYLES_QS_RIGHT": "Right",
308+
"LIVE_DEV_STYLES_QS_BOTTOM": "Bottom",
309+
"LIVE_DEV_STYLES_QS_LEFT": "Left",
294310
"LIVE_DEV_STYLES_QS_SHOW_MORE": "Show More",
295311
"LIVE_DEV_STYLES_QS_SHOW_LESS": "Show Less",
296312
"LIVE_DEV_STYLES_TAB_QUICK": "Quick Styles",

0 commit comments

Comments
 (0)