You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Any invisible component in drawer breaks Aura theme in AppLayout #11212
The light background in the AppLayout dissappears if there is any invisible component in the drawer.
@Route@StyleSheet(Aura.STYLESHEET)
publicclassMainViewextendsVerticalLayout {
@LayoutpublicstaticclassMainLayoutextendsAppLayout {
publicMainLayout() {
addToDrawer(newParagraph("Menu"));
addToDrawer(newParagraph("Hidden item"){{
// Setting something invisible in the drawer breaks Aura theme// in app layout, content area color is lostsetVisible(false);
}});
}
}
publicMainView() {
add(newH1("It works!? This main part should have light background color"));
}
}
Expected outcome
Should work
Minimal reproducible example
Use the code above
Steps to reproduce
Use the app above
Environment
Flow: 25.1-SNAPSHOT
Vaadin: 25.1-SNAPSHOT
Spring Boot: 4.0.1
Spring: 7.0.2
Copilot: 25.1-SNAPSHOT
Frontend Hotswap: Pre-Built Bundle
OS: aarch64 Mac OS X 26.3
Java: Azul Systems, Inc. 25
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.3 Safari/605.1.15
Java Hotswap: Hotswap is disabled
IDE Plugin: 1.5.10 IntelliJ
The problem is that even though the paragraph component is added to the drawer, it doesn't get the slot="drawer" attribute in the DOM. Aura adds the background color only if there’s a single content element in the App Layout. Now there are two, the <p> and the <vaadin-vertical-layout>:
I wonder if Flow’s implementation for hidden components can be updated to allow certain attributes to be sent to the client?
One workaround could be to offer a classname in Aura, which you can explicitly add to the App Layout content element, for cases like this when the structural selector doesn't match.
Omitting the slot attribute can definitely cause issues in any css or js that relies on the existence (or number of) elements in the default slot. Would be good if Flow's hidden mechanism would not omit that attribute at least.
Flow prevents attributes from being sent to the client for invisible elements for security reasons: if an element is hidden initially, only an empty placeholder should be sent to the client with no value and no other data that may reveal the backend data.
When an element is set as invisible via setVisible(false):
Server-side: The ElementData.setVisible(false) is called (ElementData.java:112), which sets the VISIBLE property to false in the state node
Client-side: The SimpleElementBindingStrategy detects the invisible state and calls setElementInvisible() (SimpleElementBindingStrategy.java:655), which only sets the hidden attribute and display: none.
The problem: When an element is initially invisible, it's only partially bound (SimpleElementBindingStrategy.java:718-721). The full binding process (including ELEMENT_ATTRIBUTES which contains the slot attribute) is deferred until the element becomes visible.
This means the slot="drawer" attribute is never sent to/set on the client DOM for invisible elements, causing the Aura theme's structural CSS selector (:host(:not([overlay])) [slot]:not([slot=navbar]):not([slot=drawer]):only-child) to incorrectly match the content area.
Possible solutions:
Preserve critical attributes during invisible state: Modify the visibility mechanism to always send certain "structural" attributes (like slot) even when the element is invisible. This could be done by:
Always binding ELEMENT_ATTRIBUTES before checking visibility, or
Maintaining a whitelist of attributes that should be set even for invisible elements
Change hiding strategy: Instead of deferring the full binding, fully bind the element first (including all attributes), then hide it with hidden and display: none. This ensures all structural attributes are present in the DOM, but violates the security design.
So I'd go with (1) - collecting the "allowed list" of attributes that are critical for theming and send them even for partially bound elements.
Option 1 seems a good choice. The allowed list of attributes will probably contain only the slot attribute for now.
I don't see any security issues in propagating the slot attribute, since it is related to layout and CSS rather than application data.
I don't know if a hidden element with a slot attribute might cause some visual issues, though.
I don't know if a hidden element with a slot attribute might cause some visual issues, though.
Only if the component that the slot is part of would expect it to be empty when hidden, but since that's not expected outside of Flow, I don't think any of our components make such assumptions. And if they do, we can adjust them to take hidden into account.
Bit late to the party, but to me the fix (vaadin/flow#24037) looks quite a hack for the original issue. I don't doubt it works, but I think our framework is already too complex before this change. I wonder why we are sending the element/component to the client in the first place if it is invisible? Nothing else is sent to the client, why send it at all 🤷♂️ Changing that would also fix the original issue 🤔
If it wasn't sent to the client, then what would be the difference between making it invisible and not attaching it? I don't exactly know what were the initial implications of this design, but I guess the semantics is correct - invisible should be a part of the DOM and should be synchronized with the server. If we decide to change this, the major architectural refactoring would be needed on the client side and this could be also a breaking change for end-to-end tests or even production code.
The first reasoning there is premature optimisation (that can still be done in different way if needed with more control). Don't remember how the "id mapping" related to polymer integration affected this or if that is still relevant 🤷♂️
Activity
jouni commentedon Feb 27, 2026
The problem is that even though the paragraph component is added to the drawer, it doesn't get the
slot="drawer"attribute in the DOM. Aura adds the background color only if there’s a single content element in the App Layout. Now there are two, the<p>and the<vaadin-vertical-layout>:I wonder if Flow’s implementation for hidden components can be updated to allow certain attributes to be sent to the client?
One workaround could be to offer a classname in Aura, which you can explicitly add to the App Layout content element, for cases like this when the structural selector doesn't match.
rolfsmeds commentedon Feb 27, 2026
Omitting the
slotattribute can definitely cause issues in any css or js that relies on the existence (or number of) elements in the default slot. Would be good if Flow'shiddenmechanism would not omit that attribute at least.Thoughts, @mshabarov ?
mshabarov commentedon Mar 5, 2026
Flow prevents attributes from being sent to the client for invisible elements for security reasons: if an element is hidden initially, only an empty placeholder should be sent to the client with no value and no other data that may reveal the backend data.
When an element is set as invisible via
setVisible(false):ElementData.setVisible(false)is called (ElementData.java:112), which sets the VISIBLE property to false in the state nodeSimpleElementBindingStrategydetects the invisible state and callssetElementInvisible()(SimpleElementBindingStrategy.java:655), which only sets the hidden attribute anddisplay: none.The problem: When an element is initially invisible, it's only partially bound (
SimpleElementBindingStrategy.java:718-721). The full binding process (including ELEMENT_ATTRIBUTES which contains the slot attribute) is deferred until the element becomes visible.This means the
slot="drawer"attribute is never sent to/set on the client DOM for invisible elements, causing the Aura theme's structural CSS selector (:host(:not([overlay])) [slot]:not([slot=navbar]):not([slot=drawer]):only-child) to incorrectly match the content area.Possible solutions:
display: none. This ensures all structural attributes are present in the DOM, but violates the security design.So I'd go with (1) - collecting the "allowed list" of attributes that are critical for theming and send them even for partially bound elements.
mcollovati commentedon Mar 27, 2026
Option 1 seems a good choice. The allowed list of attributes will probably contain only the
slotattribute for now.I don't see any security issues in propagating the
slotattribute, since it is related to layout and CSS rather than application data.I don't know if a hidden element with a
slotattribute might cause some visual issues, though.fix: preserve slot attribute for initially invisible elements
fix: preserve slot attribute for initially invisible elements
rolfsmeds commentedon Mar 27, 2026
Only if the component that the slot is part of would expect it to be empty when hidden, but since that's not expected outside of Flow, I don't think any of our components make such assumptions. And if they do, we can adjust them to take
hiddeninto account.fix: preserve slot attribute for initially invisible elements (#24037)
fix: preserve slot attribute for initially invisible elements (#24037)
fix: preserve slot attribute for initially invisible elements (#24037)
fix: preserve slot attribute for initially invisible elements (#24037)…
mstahv commentedon Mar 30, 2026
Bit late to the party, but to me the fix (vaadin/flow#24037) looks quite a hack for the original issue. I don't doubt it works, but I think our framework is already too complex before this change. I wonder why we are sending the element/component to the client in the first place if it is invisible? Nothing else is sent to the client, why send it at all 🤷♂️ Changing that would also fix the original issue 🤔
fix: preserve slot attribute for initially invisible elements (#24037)…
mshabarov commentedon Mar 31, 2026
If it wasn't sent to the client, then what would be the difference between making it invisible and not attaching it? I don't exactly know what were the initial implications of this design, but I guess the semantics is correct - invisible should be a part of the DOM and should be synchronized with the server. If we decide to change this, the major architectural refactoring would be needed on the client side and this could be also a breaking change for end-to-end tests or even production code.
mcollovati commentedon Mar 31, 2026
I found this comment, but I don't know if it is still valid or if something has changed in the meantime.
mstahv commentedon Mar 31, 2026
The first reasoning there is premature optimisation (that can still be done in different way if needed with more control). Don't remember how the "id mapping" related to polymer integration affected this or if that is still relevant 🤷♂️