From c765dcbac4148762768d8c2bea9103e7d38c510b Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 7 Nov 2023 12:08:06 -0500 Subject: [PATCH] fix(inputs): remove invalid legacy warnings in input, textarea, and select (#28484) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue number: N/A --------- ## What is the current behavior? When using an `ion-label` as a `label` slot inside of an `ion-input`, `ion-textarea` or `ion-select` it erroneously flags the input as a legacy component and ignores the `label-placement`:
Code Result
<ion-item>
  <ion-input label-placement="floating">
    <ion-label slot="label">
      <ion-icon name="home"></ion-icon>
      Slotted Label
    </ion-label>
  </ion-input>
</ion-item>
<ion-item>
  <ion-input label-placement="floating" value="Value">
    <ion-label slot="label">
      <ion-icon name="person"></ion-icon>
      Slotted Label
    </ion-label>
  </ion-input>
</ion-item>
      
Screenshot 2023-11-07 at 10 37 43 AM ## What is the new behavior? Adds `ion-input`, `ion-textarea`, and `ion-select` as components that can contain a named label slot so it no longer assumes that they are legacy components.
Code Result
<ion-item>
  <ion-input label-placement="floating">
    <ion-label slot="label">
      <ion-icon name="home"></ion-icon>
      Slotted Label
    </ion-label>
  </ion-input>
</ion-item>
<ion-item>
  <ion-input label-placement="floating" value="Value">
    <ion-label slot="label">
      <ion-icon name="person"></ion-icon>
      Slotted Label
    </ion-label>
  </ion-input>
</ion-item>
      
## Does this introduce a breaking change? - [ ] Yes - [x] No --- core/src/utils/forms/form-controller.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/src/utils/forms/form-controller.ts b/core/src/utils/forms/form-controller.ts index 0a7c628be0..d905d5ecdf 100644 --- a/core/src/utils/forms/form-controller.ts +++ b/core/src/utils/forms/form-controller.ts @@ -48,11 +48,6 @@ export type LegacyFormController = { }; const hasLabelSlot = (controlEl: HTMLElement) => { - const root = controlEl.shadowRoot; - if (root === null) { - return false; - } - /** * Components that have a named label slot * also have other slots, so we need to query for @@ -74,5 +69,5 @@ const hasLabelSlot = (controlEl: HTMLElement) => { return false; }; -const NAMED_LABEL_SLOT_COMPONENTS = ['ION-RANGE']; +const NAMED_LABEL_SLOT_COMPONENTS = ['ION-INPUT', 'ION-TEXTAREA', 'ION-SELECT', 'ION-RANGE']; const UNNAMED_LABEL_SLOT_COMPONENTS = ['ION-TOGGLE', 'ION-CHECKBOX', 'ION-RADIO'];