fix focus events subscriptions
This commit is contained in:
1 parent
ad374a8b9d
commit
9121d68d84
2 files changed
+6
-4
No files matched your search
@@ -31,6 +31,7 @@ rustc-hash = "1.1.0"
|
||||
anymap = "1.0.0-beta.2"
|
||||
futures-channel = "0.3.25"
|
||||
shipyard = { version = "0.6.2", features = ["proc", "std"], default-features = false }
|
||||
once_cell = "1.17.1"
|
||||
|
||||
[dev-dependencies]
|
||||
dioxus = { path = "../dioxus" }
|
||||
|
||||
@@ -7,6 +7,8 @@ use dioxus_native_core::{
|
||||
Dependancy, NodeId, RealDom, SendAnyMap, State,
|
||||
};
|
||||
use dioxus_native_core_macro::partial_derive_state;
|
||||
use once_cell::sync::Lazy;
|
||||
use rustc_hash::FxHashSet;
|
||||
use shipyard::Component;
|
||||
use shipyard::{Get, ViewMut};
|
||||
|
||||
@@ -108,9 +110,7 @@ impl State for Focus {
|
||||
} else if node_view
|
||||
.listeners()
|
||||
.and_then(|mut listeners| {
|
||||
listeners
|
||||
.any(|l| FOCUS_EVENTS.binary_search(&l).is_ok())
|
||||
.then_some(())
|
||||
listeners.any(|l| FOCUS_EVENTS.contains(&l)).then_some(())
|
||||
})
|
||||
.is_some()
|
||||
{
|
||||
@@ -140,7 +140,8 @@ impl State for Focus {
|
||||
}
|
||||
}
|
||||
|
||||
const FOCUS_EVENTS: &[&str] = &["keydown", "keypress", "keyup"];
|
||||
static FOCUS_EVENTS: Lazy<FxHashSet<&str>> =
|
||||
Lazy::new(|| ["keydown", "keypress", "keyup"].into_iter().collect());
|
||||
const FOCUS_ATTRIBUTES: &[&str] = &["tabindex"];
|
||||
|
||||
pub(crate) struct FocusState {
|
||||
|
||||
Reference in new issue
Block a user