Skip to content

Support ToggleEvent for on:toggle #4361

@azriel91

Description

@azriel91

Heya, currently on:toggle only provides an Event, whereas web_sys supported ToggleEvent (MDN) since 0.2.93 (search for "Popover API", wasm-bindgen/wasm-bindgen#3977 -- gen_ToggleEvent.rs got added here).

Describe the solution you'd like

I'd like to have a ToggleEvent so that the new_state method can be called, so I can set a signal on a bool.

I'm using this on a <details> element, and based on the open state, I change the <summary> text.

Describe alternatives you've considered

Using an <input> element's checked state, and styling sibling elements as expanded or collapsed. But I'd rather use a built-in expandable element.

Additional context

I've tested my project with this code and it works: #4362

It is a breaking change if there is code that explicitly uses |event: Event| as the parameter, but I think it's source compatible if they used an inferred type parameter and don't pass it somewhere else that is strict on the type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions