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

PanicOnCloneAttr when using Icon under a Tooltip #389

Open
geovie opened this issue Mar 5, 2025 · 3 comments
Open

PanicOnCloneAttr when using Icon under a Tooltip #389

geovie opened this issue Mar 5, 2025 · 3 comments
Milestone

Comments

@geovie
Copy link
Contributor

geovie commented Mar 5, 2025

I'm not sure if this is a thaw issue or a leptos issue or somewhere in between 😅

The following code snippet crashes in csr using trunk serve

use leptos::prelude::*;
use thaw::*;

fn main() {
    mount_to_body(move || {
        view! {
            <ConfigProvider>
                <Tooltip content="Locked">
                    <Icon icon=icondata::AiLockOutlined />
                </Tooltip>
            </ConfigProvider>
        }
    })
}

with the following panic:

Image

And switching the Icon with a Button results in no crash:

<Tooltip content="Locked">
  <Button icon=icondata::AiLockOutlined />
</Tooltip>

and also surrounding the icon with a div solves the panic:

<Tooltip content="Locked">
  <div>
    <Icon icon=icondata::AiLockOutlined />
  </div>
</Tooltip>

🤷

@luoxiaozero
Copy link
Collaborator

luoxiaozero commented Mar 6, 2025

This is a Thaw problem, because Tooltip requires its child to implement AddAnyAttr and Icon returns a function, so it panics.

@luoxiaozero
Copy link
Collaborator

In v0.5, I can solve this problem by changing the icon property type of Icon, changing Signal<icondata_core::Icon> to icondata_core::Icon, so that there is no need to return a function.

@luoxiaozero luoxiaozero added this to the 0.5 milestone Mar 7, 2025
@geovie
Copy link
Contributor Author

geovie commented Mar 7, 2025

Thanks a lot! I was wondering why Button works, but now I know 👍 and the workaround is easy enough

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