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 () => {
|
||||
document.removeEventListener('click', handleClick, true);
|
||||
window.onbeforeunload = null;
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@ -177,6 +177,14 @@ const StatePlugin: React.FC<IStatePlugin> = ({ composeId, isWysiwyg }) => {
|
||||
checkHashtagCasingSuggestions(editorState);
|
||||
getQuoteSuggestions(plainText);
|
||||
detectLanguage(plainText);
|
||||
if (isEmpty) {
|
||||
window.onbeforeunload = null;
|
||||
} else {
|
||||
window.onbeforeunload = (event) => {
|
||||
event.preventDefault();
|
||||
event.returnValue = true;
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
}, [editor]);
|
||||
|
||||
Reference in New Issue
Block a user