Skip to content

Elements schedule updates after an update completed #42

@Rhaoma

Description

@Rhaoma

Describe the bug
Several of our elements seem to schedule updates after an update completed.
It is a Lit emitted warning when using a development bundled version, but I only discovered it due to the fact I'm locally bundling Lit and not loading it from a CDN (jsDelivr).

I havent looked into the cause yet, and it might be that this is needed/intended behavior, but I think it should be noted.

Below are a list of warnings emitted by Lit upon page load of a docs page
Image

Components known to schedule updates after a completed update:

  • m3e-bottom-sheet
  • m3e-drawer-container
  • m3e-form-field
  • m3e-list-item
  • m3e-list-item-button
  • m3e-list-item-option
  • m3e-slider-group
  • m3e-toc
  • m3e-circular-progress-indicator
  • m3e-linear-progress-indicator
  • m3e-slide-group
Image

The official docs page doesn't emit the warnings even though Lit is in dev mode.
It seems that when checking whether a warning should be emitted the const DEV_MODE is undefined, even though it is initially set to true;

Image

To Reproduce / Reproduction Code
You can verify my findings by visiting the docs page in Chrome, set a breakpoint at source https://cdn.jsdelivr.net/npm/@lit/reactive-element@2.1.0/src/reactive-element.ts line 1552, and enter following conditional breakpoint code, which will log every unique element who scheduled an update right after another update:

let logUpdatingElements = (name,  isUpdatePending) => {
  if (!isUpdatePending) return false;
  const globalVar = globalThis.parent;
  (globalVar.changeInUpdate ??= []); 
  if (!globalVar.changeInUpdate.includes(name)) {
    globalVar.changeInUpdate.push(name); 
    console.log(name);
  }
  return false;
}
logUpdatingElements(this.localName, this.isUpdatePending);

Navigating around the different pages will then slowly log all the relevant elements as they are shown;

Note that dependent on the browser i get different reactive-elements versions called. Optionally set a breakpoint at every one and check console output.

Please provide a minimal HTML/JS/CSS snippet or link to a repository that demonstrates the issue:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions