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

Reactive style="" overwrites style:foo. #3141

Closed
zakstucke opened this issue Oct 21, 2024 · 2 comments
Closed

Reactive style="" overwrites style:foo. #3141

zakstucke opened this issue Oct 21, 2024 · 2 comments

Comments

@zakstucke
Copy link
Contributor

zakstucke commented Oct 21, 2024

Describe the bug
Discovered during #3119. style="" and style:foo conflict and overwrite eachother.

Leptos Dependencies
Current main

To Reproduce

#[component]
pub fn App() -> impl IntoView {
    let condition = RwSignal::new(true);
    view! {
        <button
            style=move || if condition.get() { "color: red" } else { "" }
            style:background="transparent"
            on:click=move |_| condition.update(|last| *last = !*last)
        >
            "Button"
        </button>
    }
}
Screen.Recording.2024-10-21.at.18.54.25.mov
@gbj
Copy link
Collaborator

gbj commented Oct 21, 2024

This is WAD. Updating the style overwrites the entire style attribute, which will include overwriting any individual styles you've set. There isn't a way around this without expensive runtime checks -- the framework has always worked this way for style: and class: vs style and class.

@zakstucke
Copy link
Contributor Author

Noted, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants