Skip to content

0.7.0 Inline CSS properties not being removed #4389

Open
@rAAOJFnrRIBdUSOj48sKoJrrEh6cNug

Description

Problem

I have some elements that have their style attributes derived from signals. #3950 causes styles to not be removed after they've been applied.

Steps To Reproduce

use dioxus::prelude::*;

fn main() {
    dioxus::launch(App);
}

#[component]
fn App() -> Element {
    let mut toggled = use_signal(|| false);
    rsx! {
        button {
            style: if toggled() {
                "border-radius: 12px; background-color: red;"
            } else {
                "border-radius: 0px;"
            },
            onclick: move |_| {
                toggled.toggle();
            },
            {"Toggle Style"}
        }
    }
}

Steps to reproduce the behavior:

  • Click the button to set the toggled signal to on
  • The button will turn red
  • Click the button to set the toggled signal to off
  • The button will stay red

Expected behavior

The button should no longer be red once it is toggled off.

Environment:

  • Dioxus version: 0.7.0
  • App platform: web

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions