1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2025-01-10 22:45:47 +00:00

Partially prevent navigation while editor is active (ref #87)

This commit is contained in:
Felix Ableitner 2024-12-04 12:49:29 +01:00
parent 215db859f1
commit ddad6e58a8

View file

@ -1,5 +1,6 @@
use crate::frontend::markdown::render_markdown;
use leptos::{html::Textarea, prelude::*};
use leptos::{ev::beforeunload, html::Textarea, prelude::*};
use leptos_use::{use_event_listener, use_window};
#[component]
pub fn EditorView(
@ -10,6 +11,14 @@ pub fn EditorView(
let (preview, set_preview) = signal(render_markdown(&content.get_untracked()));
let (show_preview, set_show_preview) = signal(false);
// Prevent user from accidentally closing the page while editing. Doesnt prevent navigation
// within Ibis.
// https://github.com/Nutomic/ibis/issues/87
let _ = use_event_listener(use_window(), beforeunload, |evt| {
evt.stop_propagation();
evt.prevent_default();
});
view! {
<div>
<div class="my-4 w-full flex max-sm:flex-col">