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

Support for conditional children wrappers #6354

Open
lmaxyz opened this issue Sep 27, 2024 · 3 comments
Open

Support for conditional children wrappers #6354

lmaxyz opened this issue Sep 27, 2024 · 3 comments
Labels
a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request

Comments

@lmaxyz
Copy link

lmaxyz commented Sep 27, 2024

It would be nice to have possibility to make conditional containers for children.

component MyComponent {
    if condition : some_id := CustomWrapper {
        @children
    } else : VerticalLayout {
        @children
    }
}
@Enyium
Copy link
Contributor

Enyium commented Sep 27, 2024

else isn't currently supported in the context of conditional rendering. But - aside from its convenience and redundancy reduction potential - it would be a natural way in a limited local context to guarantee that only one @children is rendered. It's far from the sophistication of Rust's compile-time proofs, but it's a start.

@ogoffart ogoffart added need triaging Issue that the owner of the area still need to triage a:language-slint Compiler for the .slint language (mO,bF) labels Sep 30, 2024
@ogoffart
Copy link
Member

ogoffart commented Oct 1, 2024

Related: #6258

@ogoffart ogoffart added enhancement New feature or request and removed need triaging Issue that the owner of the area still need to triage labels Oct 1, 2024
@Enyium
Copy link
Contributor

Enyium commented Oct 5, 2024

I've just gotten the error:

The @children placeholder cannot appear in a conditional element

(SlintPad reproduction)

This was in the context of the implementation of a modal that fades out when being closed using opacity, and that shouldn't keep its subtree including @children alive while the modal isn't needed, which would be most of the time. Every modal instance's outermost element would always exist, though.

So, this changing is basically part of the request of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants