Repository navigation
Description
Stencil version:
@stencil/[email protected]
I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
The first calcite-label element rendered using this code reproduces this issue, which is not placing the slotted text node in the proper place in the DOM:
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Stencil Component Starter</title>
<script type="module" src="/build/stencil-starter-project-name.esm.js"></script>
<script nomodule src="/build/stencil-starter-project-name.js"></script>
</head>
<body>
<script type="module">
import { h, createProjector } from "https://unpkg.com/[email protected]/dist/index.js";
document.addEventListener('DOMContentLoaded', function () {
const domNode = document.body;
const projector = createProjector();
const test = {
renderMaquette: function () {
return h("div", [
h("calcite-label", ["I am a text node and won't get properly relocated"]),
h("calcite-label", [h("span", ["I am a span and will get properly relocated"])]),
])
}
};
projector.append(domNode, test.renderMaquette);
projector.scheduleRender();
});
</script>
</body>
</html>Expected behavior:
Sending in plain text (without any wrapping element) to a scoped Stencil component properly places the content in the default <slot /> position.
Steps to reproduce:
git clone https://github.com/eriklharper/stencil-maquette-bugnpm i && npm start- Open browser developer tools and inspect both rendered
calcite-labelelements. Note that the first one is not placing the text content in the proper place while the second one is.
Other information:
Repro environment: https://github.com/eriklharper/stencil-maquette-bug
This is happening in the latest Chrome (87.0.4280.141), Firefox (84.0.2), Safari (14.0.2) and Brave (1.18.78) on MacOS 10.15.7
This also appears to produce very strange behavior in a larger app that is using maquette where a calcite-panel stencil element is trying to render.
Example code (JSX rendered with maquettejs):
<calcite-label class={CSS.toggleText}>
<span class={CSS.toggleTextLabel}>{i18n.ui.includeInLegend}</span>
<calcite-switch
key="transparency-include-in-legend-toggle-switch"
class={CSS.toggleButton}
scale="s"
switched={isChecked}
afterCreate={(element: HTMLElement) => {
element.addEventListener("calciteSwitchChange", () => {
this.handleIncludeInLegendToggle();
});
}}
></calcite-switch>
</calcite-label>
In the testing I've been doing, this doesn't seem to affect named slots. It only appears to affect the default <slot />.


Activity
julio8a commentedon Jan 25, 2021
@eriklharper, is there anything we can do on our end for this? or do we need to wait on Stencil?
eriklharper commentedon Jan 25, 2021
Yes, the workaround for this specific issue is to simply use a plain
<label>in place of<calcite-label>anywhere that is having problems. Currently this workaround is in place in the areas it is affecting based on what I've seen. @AdelheidF can verify that as well on her end, but I have verified it several times and the workaround is solid for now while we wait for this fix.eriklharper commentedon Jan 26, 2021
@ionic-team have you had a chance to triage this?
rwaskiewicz commentedon Oct 22, 2021
I'm going to close this issue for now, as a fix for this was released in v2.8.1. Please feel free to open a new issue if this persists!
eriklharper commentedon Oct 22, 2021
@rwaskiewicz I'm still seeing the issue after upgrading Stencil to v2.9.0. I also tried it with v2.8.1, same result. Should I open a new issue or should we re-open this one? Also, could you clone my example repository and see if you see the same result as me? I just pushed the Stencil v2.9.0 update to https://github.com/eriklharper/stencil-maquette-bug
rwaskiewicz commentedon Oct 22, 2021
@eriklharper I put up a PR against your reproduction - I failed to mention in my comment earlier today that this fix is behind a compiler flag,
scopedSlotTextContentFix, that's my fault. That's all the PR adds. That should resolve your issue, but if there are additional cases that you uncover, please do open an additional issue. Sorry about not mentioning that flag earlier!