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
AppLayout drawer-toggle not working in RTL mode on Chrome and FF #4682
Setting UI.getCurrent.setDirection(Direction.RIGHT_TO_LEFT) in Flow seems to break the functionality of vaadin-drawer-toggle in Chrome and Firefox: the drawer-opened attribute is not toggled, and the drawer stays put. This also makes it impossible to open the drawer in small-viewport mode.
It works correctly in Safari, however.
Have not tested outside of a Flow app.
Expected outcome
Clicking the toggle should toggle the drawer.
Minimal reproducible example
public class MainLayout extends AppLayout {
public MainLayout() {
addToDrawer(new Span("Foo"));
addToNavbar(new DrawerToggle());
UI.getCurrent().setDirection(Direction.RIGHT_TO_LEFT);
}
Steps to reproduce
Use e.g. the default Start template
Add the above code to the main layout class
Run the app in Chrome or Firefox, and try clicking the toggle
My original code puts the setDirection inside the beforeEnter call, facing the same problem, so I dont think the problem is puting this inside the constructor.
<htmllang="en" dir="rtl"><head>...</head><body><vaadin-app-layout><vaadin-drawer-toggleslot="navbar"></vaadin-drawer-toggle><spanslot="drawer">Drawer</span></vaadin-app-layout><divid="container" style="height: 100%"></div><script>// Move layout to different parent after initializationsetTimeout(()=>{constlayout=document.querySelector("vaadin-app-layout");constcontainer=document.getElementById("container");container.appendChild(layout);},1000);</script></body></html>
In Flow applications the layout is always moved to a new parent during initialization by the Vaadin router. It seems that when moving the layout to a new parent, during the AppLayout.disconnectedCallback some logic in the DirMixin triggers AppLayout.connectedCallback before the disconnect callback is fully completed. That in turn causes the layout to loose the listener for the drawer toggle event.
As mentioned this only applies in Chome and FF, but not in Safari. So it seems that Chrome and FF for some reason immediately run the pending reconnect if you change an attribute, even if the disconnect has not finished yet.
Activity
vursen commentedon Oct 6, 2022
Appears to work with plain web components by the way:
Screen.Recording.2022-10-06.at.13.20.17.mov
My guess is that the issue is somehow related to the fact that RTL mode is enabled in the view constructor.
JariHanah commentedon Oct 8, 2022
My original code puts the setDirection inside the beforeEnter call, facing the same problem, so I dont think the problem is puting this inside the constructor.
sissbruecker commentedon Oct 10, 2022
Reproduction with web components only:
In Flow applications the layout is always moved to a new parent during initialization by the Vaadin router. It seems that when moving the layout to a new parent, during the
AppLayout.disconnectedCallbacksome logic in theDirMixintriggersAppLayout.connectedCallbackbefore the disconnect callback is fully completed. That in turn causes the layout to loose the listener for the drawer toggle event.The relevant line in
DirMixinis this one:web-components/packages/component-base/src/dir-mixin.js
Line 111 in e86cd2a
As mentioned this only applies in Chome and FF, but not in Safari. So it seems that Chrome and FF for some reason immediately run the pending reconnect if you change an attribute, even if the disconnect has not finished yet.
fix: avoid triggering connected callback from disconnected callback
fix: avoid triggering connected callback from disconnected callback (#…
fix: avoid triggering connected callback from disconnected callback (#…
fix: avoid triggering connected callback from disconnected callback (#…