Skip to content

Commit 717a498

Browse files
committed
fix: disbale live preview edit for html & body tags
1 parent 04c5914 commit 717a498

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,17 @@ function RemoteFunctions(config) {
227227
*/
228228
function _handleDeleteOptionClick(event, element) {
229229
const tagId = element.getAttribute("data-brackets-id");
230-
if (tagId) {
230+
231+
if (tagId && element.tagName !== "BODY" && element.tagName !== "HTML") {
231232
window._Brackets_MessageBroker.send({
232233
livePreviewEditEnabled: true,
233234
element: element,
234235
event: event,
235236
tagId: Number(tagId),
236237
delete: true
237238
});
239+
} else {
240+
console.error("The TagID might be unavailable or the element tag is directly body or html");
238241
}
239242
}
240243

@@ -245,14 +248,17 @@ function RemoteFunctions(config) {
245248
*/
246249
function _handleDuplicateOptionClick(event, element) {
247250
const tagId = element.getAttribute("data-brackets-id");
248-
if (tagId) {
251+
252+
if (tagId && element.tagName !== "BODY" && element.tagName !== "HTML") {
249253
window._Brackets_MessageBroker.send({
250254
livePreviewEditEnabled: true,
251255
element: element,
252256
event: event,
253257
tagId: Number(tagId),
254258
duplicate: true
255259
});
260+
} else {
261+
console.error("The TagID might be unavailable or the element tag is directly body or html");
256262
}
257263
}
258264

@@ -280,6 +286,8 @@ function RemoteFunctions(config) {
280286
parentElement.hasAttribute("data-brackets-id")
281287
) {
282288
parentElement.click();
289+
} else {
290+
console.error("The TagID might be unavailable or the parent element tag is directly body or html");
283291
}
284292
}
285293

@@ -1033,8 +1041,13 @@ function RemoteFunctions(config) {
10331041
*/
10341042
function onClick(event) {
10351043
// make sure that the feature is enabled and also the clicked element has the attribute 'data-brackets-id'
1036-
if(isFlagActive && event.target.hasAttribute('data-brackets-id')) {
1037-
if(_nodeMoreOptionsBox) {
1044+
if (
1045+
isFlagActive &&
1046+
event.target.hasAttribute("data-brackets-id") &&
1047+
event.target.tagName !== "BODY" &&
1048+
event.target.tagName !== "HTML"
1049+
) {
1050+
if (_nodeMoreOptionsBox) {
10381051
_nodeMoreOptionsBox.remove();
10391052
_nodeMoreOptionsBox = null;
10401053
}

src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ define(function (require, exports, module) {
5353
StringUtils = require("utils/StringUtils"),
5454
FileViewController = require("project/FileViewController"),
5555
MainViewManager = require("view/MainViewManager"),
56-
LivePreviewEdit = require("LiveDevelopment/livePreviewEdit");
56+
LivePreviewEdit = require("LiveDevelopment/LivePreviewEdit");
5757

5858
const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = `phoenix_live_preview_scripts_instrumented_${StringUtils.randomString(8)}.js`;
5959
const LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = `pageLoaderWorker_${StringUtils.randomString(8)}.js`;

0 commit comments

Comments
 (0)