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

bug(calcite-button): renders incorrectly if an HTML comment is "slotted in" #10076

Closed
2 of 6 tasks
maxpatiiuk opened this issue Aug 15, 2024 · 6 comments
Closed
2 of 6 tasks
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Maps SDK for JavaScript Issues logged by ArcGIS SDK for JavaScript team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. estimate - 3 A day or two of work, likely requires updates to tests. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - medium Issue is non core or affecting less that 60% of people using the library

Comments

@maxpatiiuk
Copy link
Member

Check existing issues

Actual Behavior

<calcite-button> thinks that it has slotted in content if you provide an HTML comment as a child to it

private updateHasContent() {
const slottedContent = this.el.textContent.trim().length > 0 || this.el.childNodes.length > 0;
this.hasContent =
this.el.childNodes.length === 1 && this.el.childNodes[0]?.nodeName === "#text"
? this.el.textContent?.trim().length > 0
: slottedContent;
}

Expected Behavior

<calcite-button> should not consider comment to be a slotted in content.

Reproduction Sample

https://codepen.io/maxpatiiuk/pen/mdZpWJb?editors=1000

Reproduction Steps

  1. Open codepen
  2. See that presence of a comment causes element to render incorrectly

Reproduction Version

2.11.1

Relevant Info

No response

Regression?

No response

Priority impact

impact - p2 - want for an upcoming milestone

Impact

When an element is rendered using lit-html templates, comments may be inserted by lit-html - we don't have much control over that. Those comments are causing calcite to not render correctly.

Our exact code in question (from the arcgis-home component in @arcgis/map-components):

        <calcite-button
          class={globalCss.widgetButton}
          disabled={state === "disabled"}
          iconStart={isLoading ? undefined : (icon ?? undefined)}
          kind="neutral"
          label={messages.componentLabel}
          onClick={this._go}
          // Workaround for https://github.com/Esri/calcite-design-system/issues/8490
          scale={isLoading ? "s" : "m"}
          title={state === "going-home" ? messages.cancel : messages.title}
        >
          {isLoading ? (
            // Cannot use calcite-button's loading=true. See https://devtopia.esri.com/WebGIS/arcgis-js-api/pull/58358#discussion_r1106927
            <calcite-loader inline label="" />
          ) : null}
        </calcite-button>

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-angular
  • @esri/calcite-components-react
  • @esri/calcite-design-tokens
  • @esri/eslint-plugin-calcite-components

Esri team

ArcGIS Maps SDK for JavaScript

@maxpatiiuk maxpatiiuk added 0 - new New issues that need assignment. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. needs triage Planning workflow - pending design/dev review. labels Aug 15, 2024
@github-actions github-actions bot added ArcGIS Maps SDK for JavaScript Issues logged by ArcGIS SDK for JavaScript team members. calcite-components Issues specific to the @esri/calcite-components package. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone labels Aug 15, 2024
@maxpatiiuk
Copy link
Member Author

I implemented a workaround, so this is no longer a must for next release, but a nice to have

@driskull
Copy link
Member

I think this could be refactored to use the slotChangeHasContent dom utility function.

This issue also applies to the calcite-text-area component.

@geospatialem geospatialem added p - medium Issue is non core or affecting less that 60% of people using the library estimate - 3 A day or two of work, likely requires updates to tests. needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. and removed needs triage Planning workflow - pending design/dev review. labels Sep 3, 2024
@geospatialem geospatialem added this to the 2025-01-28 - Jan Release milestone Sep 6, 2024
@geospatialem geospatialem removed the needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. label Sep 6, 2024
@jcfranco
Copy link
Member

This is no longer reproducible on next (most likely fixed by #10310).

@jcfranco jcfranco added the 3 - installed Issues that have been merged to master branch and are ready for final confirmation. label Dec 16, 2024
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem added 4 - verified Issues that have been released and confirmed resolved. and removed 0 - new New issues that need assignment. 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels Dec 17, 2024
@geospatialem
Copy link
Member

Verified on 3.0.0-next.68 🙌🏻

@maxpatiiuk
Copy link
Member Author

Confirmed that the issue is fixed on next.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Maps SDK for JavaScript Issues logged by ArcGIS SDK for JavaScript team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. estimate - 3 A day or two of work, likely requires updates to tests. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - medium Issue is non core or affecting less that 60% of people using the library
Projects
None yet
Development

No branches or pull requests

5 participants