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

[lumo] Overlay styles are duplicated if combo box is used together with any other overlay-based component #1697

Closed
jouni opened this issue Nov 8, 2018 · 8 comments · Fixed by #6134
Labels
refactor Internal improvement requires new major This would be a breaking change theme

Comments

@jouni
Copy link
Member

jouni commented Nov 8, 2018

Problem

If you just use <vaadin-select>, <vaadin-date-picker> or any other component that internally uses an element based on <vaadin-overlay>, styles are as expected.

When you import and use <vaadin-combo-box> together with any of them, the styles for the overlays are duplicated. There’s no visible effect from that, but it looks ugly in Devtools, and it certainly doesn't increase performance.

The reason is that combo box imports vaadin-overlay/theme/lumo/vaadin-overlay.html which adds a theme module for vaadin-overlay which includes the lumo-overlay style module.

At the same time, other components do not import vaadin-overlay/theme/lumo/vaadin-overlay.html but instead define their own theme modules for their corresponding specialized overlay elements such as <vaadin-select-overlay> and include the lumo-menu-overlay style module which then includes the lumo-overlay style module.

As theme modules are included from the inherited component as well, the overlays end up getting the lumo-overlay style module twice.

Possible solutions

  1. Do not import vaadin-overlay/theme/lumo/vaadin-overlay.html from combo-box. This only fixes the symptom, and it will break again if some other component would want to import the plain <vaadin-overlay> element and use it directly.

  2. Let all components import the Lumo styled overlay (like combo box does), and remove the include="lumo-overlay ..." from the lumo-menu-overlay theme module.

  3. Add logic to ThemableMixin to avoid including the same theme module multiple times. There’s a small risk of breaking something, as this could cause the priority of some selectors to change in users’ apps.

@lkraav
Copy link
Contributor

lkraav commented Nov 12, 2018

What would you want to go with as the top choice?

@jouni
Copy link
Member Author

jouni commented Nov 13, 2018

Hi @lkraav!

My original choice was 1, and there were no duplicated styles initially as <vaadin-overlay> was unstyled by itself.

But then we decided that the bare <vaadin-overlay> should also have some styles by default, and we didn’t pay attention to this issue resulting from it.

Now I see 2 as the correct solution. It’s, unfortunately, the solution which requires the most code changes. Not a huge effort, but needs work across multiple repos and updating versions.

3 would be good to implement as well, but as there’s a small risk for breaking some apps, I’m not sure it’s worth it.

@lkraav
Copy link
Contributor

lkraav commented Nov 13, 2018

Now I see 2 as the correct solution. It’s, unfortunately, the solution which requires the most code changes. Not a huge effort, but needs work across multiple repos and updating versions.

Thanks for your thoughts.

So for a new project, it would make sense to fork relevant component repos and just do this change while upstream is working on integrating it across all?

@jouni
Copy link
Member Author

jouni commented Nov 21, 2018

Sorry for the long delay in responding.

I’m not sure I understood what you meant (my git terminology is a bit lacking). But I think branches for the relevant components would be the way to go. I would let the core dev team handle the integration.

@jouni
Copy link
Member Author

jouni commented Nov 21, 2018

@tomivirkki, do you have any instructions/suggestions on how @lkraav could contribute here?

@lkraav
Copy link
Contributor

lkraav commented Nov 26, 2018

@tomivirkki your thoughts? Let me know if my question is unclear in some way.

@tomivirkki
Copy link
Member

Not sure if we can do much about 3. Themable mixin already prevents duplicate includes for style modules but I guess the issue here is about the includes that occur within the style modules themselves.

So that leaves us with option 2, unless we come up with something else

@lkraav
Copy link
Contributor

lkraav commented Nov 27, 2018

@tomivirkki is this a problem inherent to HTML imports? Would we be able to better control this if everything was ES modules?

@vaadin-bot vaadin-bot added refactor Internal improvement requires new major This would be a breaking change theme labels May 19, 2021
@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-lumo-styles May 19, 2021
@web-padawan web-padawan changed the title Overlay styles are duplicated if combo box is used together with any other component that uses vaadin-overlay [lumo] Overlay styles are duplicated if combo box is used together with any other overlay-based component May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Internal improvement requires new major This would be a breaking change theme
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants