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

Group element cannot add children #1

Open
MartinJanusek opened this issue Feb 13, 2021 · 2 comments
Open

Group element cannot add children #1

MartinJanusek opened this issue Feb 13, 2021 · 2 comments

Comments

@MartinJanusek
Copy link

MartinJanusek commented Feb 13, 2021

Guys, excellent work with SVG component, really straightforward and helpful.

I am experiencing issue when working with Group class. This code not working as expected

public class MainView extends HorizontalLayout {
public MainView() {        
            Svg svg = new Svg();

            Group grp = new Group("grp_id");
            grp.addElement(new Text("text_id", "Label"));
            svg.add(grp);
            
            add(svg);
        }
}

and resulting in

Error: Element with selector "[id="text_id"]" not found.

Am I doing anything wrong? Any help will be appreciated.

Thanks

Martin

Using Vaadin 16, svg 1.0.3

@mathieu-fanduel
Copy link

I think the issue is that the JsComponent does not recursively look up the id but only look at the top level https://github.com/vaadin-component-factory/vcf-svg/blob/master/src/vcf-svg.js#L374

As to how to fix it ... no idea

@sirsch
Copy link

sirsch commented Oct 1, 2021

I think you have to add the element to the svg first.

public class MainView extends HorizontalLayout {
    public MainView() {
        Svg svg = new Svg();
        Group group = new Group("group_id");
        Text text = new Text("text_id", "Label");

        svg.add(text);
        group.addElement(text);
        svg.add(group);
        this.add(svg);
    }
}

Tested with Vaadin 14.5.2, svg 1.1.1

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

3 participants