Skip to content

Commit ee9b46e

Browse files
committed
fix: element doesn’t get refreshed until mode is changed
1 parent 1b94b1d commit ee9b46e

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,10 +1232,6 @@ function RemoteFunctions(config = {}) {
12321232
_clickHighlight.add(selectedBeforeReregister);
12331233
previouslySelectedElement = selectedBeforeReregister;
12341234
window.__current_ph_lp_selected = selectedBeforeReregister;
1235-
// Restore the outline
1236-
const isEditable = selectedBeforeReregister.hasAttribute(GLOBALS.DATA_BRACKETS_ID_ATTR);
1237-
const outlineColor = isEditable ? COLORS.outlineEditable : COLORS.outlineNonEditable;
1238-
selectedBeforeReregister.style.outline = `1px solid ${outlineColor}`;
12391235
}
12401236
return JSON.stringify(config);
12411237
}

src/LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,27 @@ define(function (require, exports, module) {
737737
* Update configuration in the remote browser
738738
*/
739739
function updateConfig(config) {
740+
const previousConfig = _config;
740741
_config = config;
741742
_updateVirtualServerScripts();
742743
refreshConfig();
744+
// Clear the highlight cache only when mode or highlight-mode changes.
745+
// These changes wipe browser-side highlights (via _handleConfigurationChange),
746+
// so the editor-side cache must be reset too, otherwise highlightRule()
747+
// skips re-highlighting the same element on the next cursor activity.
748+
// We intentionally skip this for other config changes (e.g. toggling
749+
// measurements) where the selected element is preserved
750+
const modeChanged = !previousConfig || previousConfig.mode !== config.mode;
751+
const oldHighlights = previousConfig && previousConfig.elemHighlights
752+
? previousConfig.elemHighlights.toLowerCase() : "hover";
753+
const newHighlights = config.elemHighlights
754+
? config.elemHighlights.toLowerCase() : "hover";
755+
if (modeChanged || oldHighlights !== newHighlights) {
756+
const doc = getLiveDocForEditor(EditorManager.getActiveEditor());
757+
if (doc) {
758+
doc._lastHighlight = null;
759+
}
760+
}
743761
}
744762

745763
/**

0 commit comments

Comments
 (0)