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:
parent
215db859f1
commit
ddad6e58a8
1 changed files with 10 additions and 1 deletions
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue