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

Lit-based components show a warning on init [1 day] #7496

Open
tomivirkki opened this issue Jun 20, 2024 · 1 comment
Open

Lit-based components show a warning on init [1 day] #7496

tomivirkki opened this issue Jun 20, 2024 · 1 comment
Labels
DX Developer experience issue Lit Lit conversion issue needs research More information needed to estimate

Comments

@tomivirkki
Copy link
Member

tomivirkki commented Jun 20, 2024

Description

Lit-based components show a warning on init with the latest version of Lit

Element vaadin-side-nav scheduled an update (generally because a property was set) after an update completed, causing a new update to be scheduled. This is inefficient and should be avoided unless the next update can only be scheduled as a side effect of the previous update. See https://lit.dev/msg/change-in-update for more information.

Expected outcome

There should not be a warning

Minimal reproducible example

Open a page with a Lit-based Vaadin component (side-nav, popover)

Steps to reproduce

See console

Environment

Vaadin version(s): 24

Browsers

Issue is not browser related

@yuriy-fix yuriy-fix added DX Developer experience issue Lit Lit conversion issue needs research More information needed to estimate labels Jun 20, 2024
@yuriy-fix yuriy-fix changed the title Lit-based components show a warning on init Lit-based components show a warning on init [1 day] Jun 20, 2024
@web-padawan
Copy link
Member

The main reason for this is that we store references to DOM elements in reactive properties to use them in observers.
Example: the _overlayElement defined in the OverlayClassMixin and set by vaadin-popover in firstUpdated():

this._overlayElement = this.shadowRoot.querySelector('vaadin-popover-overlay');

So, immediately after initial render there is another update caused by setting this reference, which causes the warning.
Same applies to many cases of adding controllers in ready() e.g. TextFieldMixin and other field components.

I'd say this case generally falls into the following exception which is stated in the warning itself though:

the next update can only be scheduled as a side effect of the previous update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer experience issue Lit Lit conversion issue needs research More information needed to estimate
Projects
None yet
Development

No branches or pull requests

3 participants