Skip to content

Commit 1a81c82

Browse files
committed
fix: error when click highlight is null and adding a selector to that
1 parent ce28217 commit 1a81c82

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,9 @@ function RemoteFunctions(config) {
213213
* @param {DOMElement} element - the HTML DOM element that was clicked
214214
*/
215215
function _handleAIOptionClick(event, element) {
216-
// make sure there is no existing AI prompt box, also remove more options box
217-
dismissAIPromptBox();
218-
dismissNodeMoreOptionsBox();
219-
220-
// create a new AI prompt box
221-
_aiPromptBox = new AIPromptBox(element);
216+
// make sure there is no existing AI prompt box, and no other box as well
217+
dismissAllUIBoxes();
218+
_aiPromptBox = new AIPromptBox(element); // create a new one
222219
}
223220

224221
/**
@@ -2094,9 +2091,6 @@ function RemoteFunctions(config) {
20942091
var _aiPromptBox;
20952092
var _setup = false;
20962093

2097-
2098-
/** Event Handlers ***********************************************************/
2099-
21002094
function onMouseOver(event) {
21012095
if (_validEvent(event)) {
21022096
// Skip highlighting for HTML, BODY tags and elements inside HEAD
@@ -2359,7 +2353,9 @@ function RemoteFunctions(config) {
23592353
for (i = 0; i < nodes.length; i++) {
23602354
highlight(nodes[i]);
23612355
}
2362-
_clickHighlight.selector = rule;
2356+
if (_clickHighlight) {
2357+
_clickHighlight.selector = rule;
2358+
}
23632359

23642360
// select the first valid highlighted element
23652361
var foundValidElement = false;

src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ define(function (require, exports, module) {
166166
}
167167
const allOpenFileCount = MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES);
168168
function selectInHTMLEditor(fullHtmlEditor) {
169-
const position = HTMLInstrumentation.getPositionFromTagId(fullHtmlEditor, parseInt(tagId, 10)).from;
170-
if(position && fullHtmlEditor) {
169+
const positionResult = HTMLInstrumentation.getPositionFromTagId(fullHtmlEditor, parseInt(tagId, 10));
170+
if(positionResult && positionResult.from && fullHtmlEditor) {
171+
const position = positionResult.from;
171172
const masterEditor = fullHtmlEditor.document._masterEditor || fullHtmlEditor;
172173
masterEditor.setCursorPos(position.line, position.ch, true);
173174
_focusEditorIfNeeded(masterEditor, nodeName, contentEditable);

0 commit comments

Comments
 (0)