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:
nicole mikołajczyk
2026-02-07 21:13:06 +01:00
parent e4f56e1623
commit 796162af31
2 changed files with 9 additions and 0 deletions

View File

@ -278,6 +278,7 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
return () => {
document.removeEventListener('click', handleClick, true);
window.onbeforeunload = null;
};
}, []);

View File

@ -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]);