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

fix(calcite-radio-button): fixing issue where input isn't properly initialized in some cases #1011

Merged
merged 4 commits into from
Sep 18, 2020

Conversation

eriklharper
Copy link
Contributor

Related Issue: #977

I tested this on a local running instance of arcgis-webviewer-app without the workarounds that @kevindoshier was using as a temporary fix and I could not reproduce the bug, which consisted of unrendered input tags that correspond to each radio the second (and all subsequent) time(s) that the Map properties time slider options panel was opened.

Kevin wasn't able to verify these fixes on his local copy, but despite that these fixes make sense to commit anyway because it makes radio and checkbox more consistent with how all other calcite components create input elements. We'll see once this makes it into a release and the webviewer can update calcite to see if this truly fixes the problem.

@eriklharper eriklharper requested a review from a team as a code owner September 18, 2020 19:23
@@ -180,10 +180,6 @@ export class CalciteCheckbox {
if (!scale.includes(this.scale)) this.scale = "m";
}

disconnectedCallback() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? Seems like the hidden input will get appended twice if the checkbox is removed and added back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is intentional. When the component disconnects from the DOM, because the input is a child, it also gets destroyed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already discussed in Teams, but posting for posterity:

it also gets destroyed.

It shouldn't be. You can see this in the following example:

import { Component, Element, h } from "@stencil/core";
@Component({
  tag: "calcite-example",
  shadow: true
})
export class CalciteExample {
  @Element()
  el: HTMLCalciteExampleElement;
  someEl: HTMLElement = null;
  connectedCallback(): void {
    this.someEl = document.createElement("div");
    this.el.appendChild(this.someEl);
  }
}
let example = document.createElement("calcite-example");
setInterval(() => {
  document.body.append(example);
  console.log("current element children", example.children.length);
  example.remove();
}, 1000);

Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a concern regarding the cleanup of the checkbox's internal input. Once this is addressed, this is good to merge!

@eriklharper eriklharper changed the title fix(calcite-radio-button): creating input element on document directly instead of ownerDocument and removing redundant child input element removal code fix(calcite-radio-button): fixing issue where input isn't properly initialized in some cases Sep 18, 2020
@eriklharper eriklharper merged commit 2f59ea6 into master Sep 18, 2020
@eriklharper eriklharper deleted the 977/radio-button-destroy-error branch September 18, 2020 22:56
@eriklharper eriklharper linked an issue Sep 21, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: calcite-radio-button: destroying throws errors
2 participants