-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Feature Request
Some attributes specific to different elements conflict with global attributes. For instance, if we slightly modify an example from the docs to extend input instead of button,
fn app() -> Element {
rsx! {
Input {
// A global AND an input-specific attribute
width: "10px",
// An input-specific attribute
disabled: true,
}
}
}
#[component]
fn Input(
#[props(extends = GlobalAttributes, extends = input)]
attributes: Vec<Attribute>,
) -> Element {
rsx! {
input { ..attributes }
}
}we get
error[E0034]: multiple applicable items in scope
--> src/main.rs:18:13
|
18 | width: "10px",
| ^^^^^ multiple `width` found
|
note: candidate #1 is defined in an impl of the trait `dioxus::prelude::GlobalAttributesExtension` for the type `InputPropsBuilder<(__attributes,)>`
note: candidate #2 is defined in an impl of the trait `dioxus::prelude::InputExtension` for the type `InputPropsBuilder<(__attributes,)>`
This is because width is both a global and an input-specific attribute. It is not precisely a bug, the docs clearly state this behaviour. Still, it would be nice to be able to write code like the example above. The element-specific attributes (candidate #2 in the error message) should be preffered over the global ones.
I've come accross this with width, height and autofocus.
Implement Suggestion
Maybe just deleting the element-specific attributes (like deleting this line) would solve this, but I'm afraid it's not that simple. The conflicting attributes might have different types (?), which could be an issue, but I'm not sure.