Skip to content

Commit ccf87e1

Browse files
committed
fix: toast message not disappearing when switched to preview mode
1 parent 5732d52 commit ccf87e1

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,7 +3845,7 @@ function RemoteFunctions(config = {}) {
38453845
// if element is not editable and user clicks on it, then we show a toast notification saying
38463846
// that this element is not editable
38473847
if (!element.hasAttribute("data-brackets-id")) {
3848-
showToast(config.strings.toastNotEditable);
3848+
showToastMessage(config.strings.toastNotEditable);
38493849
}
38503850

38513851
// make sure that the element is actually visible to the user
@@ -4540,6 +4540,7 @@ function RemoteFunctions(config = {}) {
45404540
dismissAIPromptBox();
45414541
dismissNodeInfoBox();
45424542
dismissImageRibbonGallery();
4543+
dismissToastMessage();
45434544
}
45444545

45454546
let _toastTimeout = null;
@@ -4549,15 +4550,9 @@ function RemoteFunctions(config = {}) {
45494550
* this toast message is used when user tries to edit a non-editable element
45504551
* @param {String} message - the message to display in the toast
45514552
*/
4552-
function showToast(message) {
4553+
function showToastMessage(message) {
45534554
// clear any existing toast & timer, if there are any
4554-
const existingToast = window.document.getElementById('phoenix-toast-notification');
4555-
if (existingToast) {
4556-
existingToast.remove();
4557-
}
4558-
if (_toastTimeout) {
4559-
clearTimeout(_toastTimeout);
4560-
}
4555+
dismissToastMessage();
45614556

45624557
// create a new fresh toast container
45634558
const toast = window.document.createElement('div');
@@ -4619,6 +4614,21 @@ function RemoteFunctions(config = {}) {
46194614
}, 3000);
46204615
}
46214616

4617+
/**
4618+
* this function is to dismiss the toast message
4619+
* and clear its timeout (if any)
4620+
*/
4621+
function dismissToastMessage() {
4622+
const toastMessage = window.document.getElementById('phoenix-toast-notification');
4623+
if (toastMessage) {
4624+
toastMessage.remove();
4625+
}
4626+
if (_toastTimeout) {
4627+
clearTimeout(_toastTimeout);
4628+
}
4629+
_toastTimeout = null;
4630+
}
4631+
46224632
/**
46234633
* Helper function to cleanup previously clicked element highlighting and state
46244634
*/

0 commit comments

Comments
 (0)