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
The ComponentRenderer, uses a parent container for all of the rendered Component instances that get passed to the client. The container gets added as a virtual child to the owner component so it doesn't automatically appear in the DOM on the browser. The individual child components originally included in the container get picked to the DOM on demand, for example, to the Grid column cells, when you scroll the Grid.
Some Flow components add internal JS executions that access the Web Component public API and Flow runs the executions for virtual child components even if they haven't actually been placed in the DOM. This is typically fine. However, in certain cases, accessing the Web Component public API may internally end up accessing the shadow DOM, etc, but since the element isn't actually in the DOM yet, the shadow DOM / internal props such as this.$ may have not yet been initialized and an error gets thrown.
It's debatable whether this should be fixed in the Web Components so that, for example, calling dangerouslySetHtmlValue for an unattached <vaadin-rich-text-editor> wouldn't throw an exception:
The issue could also be fixed by appending the container to the owner as a regular child instead of a virtual child. As a consequence, there would be an additional hidden element in the DOM of the ComponentRenderer owners:
yuriy-fix
changed the title
Components added with ComponentRenderer can cause client-side errors
Components added with ComponentRenderer can cause client-side errors [2 days]
Jan 18, 2023
It's debatable whether this should be fixed in the Web Components so that, for example, calling dangerouslySetHtmlValue for an unattached wouldn't throw an exception
It's better to fix the possible issues in the web components (for example vaadin/web-components#6871) instead of changing how the ComponentRenderer works, which would be more like a workaround for the root cause.
Description
The
ComponentRenderer
, uses a parent container for all of the renderedComponent
instances that get passed to the client. The container gets added as a virtual child to the owner component so it doesn't automatically appear in the DOM on the browser. The individual child components originally included in the container get picked to the DOM on demand, for example, to theGrid
column cells, when you scroll theGrid
.Some Flow components add internal JS executions that access the Web Component public API and Flow runs the executions for virtual child components even if they haven't actually been placed in the DOM. This is typically fine. However, in certain cases, accessing the Web Component public API may internally end up accessing the shadow DOM, etc, but since the element isn't actually in the DOM yet, the shadow DOM / internal props such as
this.$
may have not yet been initialized and an error gets thrown.It's debatable whether this should be fixed in the Web Components so that, for example, calling
dangerouslySetHtmlValue
for an unattached<vaadin-rich-text-editor>
wouldn't throw an exception:The issue could also be fixed by appending the container to the owner as a regular child instead of a virtual child. As a consequence, there would be an additional hidden element in the DOM of the
ComponentRenderer
owners:The container can be removed from the DOM programmatically in case it's considered problematic to have it there
Related issues:
Expected outcome
Client-side exceptions shouldn't occur.
Minimal reproducible example
See #4551
Steps to reproduce
See #4551
Environment
Vaadin version(s): 23+ (probably also V14)
Browsers
Issue is not browser related
The text was updated successfully, but these errors were encountered: