pl-fe: ask for confirmation before closing a tab when composing post
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -278,6 +278,7 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('click', handleClick, true);
|
document.removeEventListener('click', handleClick, true);
|
||||||
|
window.onbeforeunload = null;
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@ -177,6 +177,14 @@ const StatePlugin: React.FC<IStatePlugin> = ({ composeId, isWysiwyg }) => {
|
|||||||
checkHashtagCasingSuggestions(editorState);
|
checkHashtagCasingSuggestions(editorState);
|
||||||
getQuoteSuggestions(plainText);
|
getQuoteSuggestions(plainText);
|
||||||
detectLanguage(plainText);
|
detectLanguage(plainText);
|
||||||
|
if (isEmpty) {
|
||||||
|
window.onbeforeunload = null;
|
||||||
|
} else {
|
||||||
|
window.onbeforeunload = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, [editor]);
|
}, [editor]);
|
||||||
|
|||||||
Reference in New Issue
Block a user