Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enable_prevent_default option for KeyboardService #1286

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions yew/src/services/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cfg_if! {
use stdweb::web::event::{ConcreteEvent, KeyDownEvent, KeyPressEvent, KeyUpEvent};
use stdweb::web::{EventListenerHandle, IEventTarget};
} else if #[cfg(feature = "web_sys")] {
use gloo::events::EventListener;
use gloo::events::{EventListener,EventListenerOptions};
use wasm_bindgen::JsCast;
use web_sys::{Event, EventTarget, KeyboardEvent};
}
Expand Down Expand Up @@ -138,8 +138,13 @@ fn register_key_impl<T: AsRef<EventTarget>>(
.clone();
callback.emit(event);
};

KeyListenerHandle(EventListener::new(element.as_ref(), event, listener))
let options = EventListenerOptions::enable_prevent_default();
KeyListenerHandle(EventListener::new_with_options(
element.as_ref(),
event,
options,
listener,
))
}

#[cfg(feature = "std_web")]
Expand Down