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

html tags not showing up in SVG Foreign object #3034

Open
JmsPae opened this issue Dec 11, 2022 · 0 comments · May be fixed by #3629
Open

html tags not showing up in SVG Foreign object #3034

JmsPae opened this issue Dec 11, 2022 · 0 comments · May be fixed by #3629
Labels

Comments

@JmsPae
Copy link

JmsPae commented Dec 11, 2022

I'm reasonably certain that I've got the namespaces all correct, but I'll have a go at declaring prefixes for the XML.

My component, NodeComponent, view looks like this...

html! {
    <g ref={self.group_ref.clone()} transform={format!("translate({} {})", props.geometry.x-(sx/2), props.geometry.y-(sy/2))}>
    
        <rect ref={self.svg_ref.clone()}  
            width={sx.to_string()} height={sy.to_string()} 
            rx=5
            style="fill:white; stroke:grey; stroke-width:1"></rect>

        <image href="static/person-40.png" height="40" width="40" x="5" y="5"></image>


        <@{"foreignObject"} ref={self.text_ref.clone()} x="45" y="0" width="150" height="50">
            {"Works!"}
            <div xmlns="http://www.w3.org/1999/xhtml">{"Doesn't work!"}</div>
        </@>
    </g>
}

... And the parent in which the component is predominantly used...

html! {
    <svg ref={self.svg_ref.clone()} width="100%" height="100%"
        onpointermove={_ctx.link().callback(|e| TreeCanvasMsg::MouseMove(e))} 
        onpointerdown={_ctx.link().callback(|_| TreeCanvasMsg::MouseDown)}
        onpointerup={_ctx.link().callback(|_| TreeCanvasMsg::MouseUp)}
        onpointerleave={_ctx.link().callback(|_| TreeCanvasMsg::MouseUp)}
        style="touch-action: none"
        xmlns="http://www.w3.org/2000/svg">

        ....
        
        <g ref={self.transform_ref.clone()} transform={format!("translate({} {})", self.vx, self.vy)}> 
            ...
            <NodeComponent geometry={NodeGeometry {
                x: 0,
                y: 0
            }}/>

            <NodeComponent geometry={NodeGeometry {
                x: 250,
                y: 0
            }}/>

        </g>
    </svg>
}

And the result:
image

For some reason the un-tagged text in the foreignObject is working just fine, but the second I use any HTML tag it just doesn't want to work. Maybe it's not happy with me segmenting all this SVG into different components?

Environment:

  • Yew version: v0.20
  • Rust version: 1.65.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant