diff --git a/core/src/components/input/input.scss b/core/src/components/input/input.scss index ba8b00312f9..4a18956e01b 100644 --- a/core/src/components/input/input.scss +++ b/core/src/components/input/input.scss @@ -477,7 +477,8 @@ * then the element should be hidden otherwise * there will be additional margins added. */ -.label-text-wrapper-hidden { +.label-text-wrapper-hidden, +.input-outline-notch-hidden { display: none; } diff --git a/core/src/components/input/input.tsx b/core/src/components/input/input.tsx index b1630ff0bc4..25332f76add 100644 --- a/core/src/components/input/input.tsx +++ b/core/src/components/input/input.tsx @@ -1,10 +1,12 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core'; -import { Build, Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core'; +import { Build, Component, Element, Event, Host, Method, Prop, State, Watch, forceUpdate, h } from '@stencil/core'; import type { LegacyFormController, NotchController } from '@utils/forms'; import { createLegacyFormController, createNotchController } from '@utils/forms'; import type { Attributes } from '@utils/helpers'; import { inheritAriaAttributes, debounceEvent, findItemLabel, inheritAttributes } from '@utils/helpers'; import { printIonWarning } from '@utils/logging'; +import { createSlotMutationController } from '@utils/slot-mutation-controller'; +import type { SlotMutationController } from '@utils/slot-mutation-controller'; import { createColorClasses, hostContext } from '@utils/theme'; import { closeCircle, closeSharp } from 'ionicons/icons'; @@ -33,9 +35,9 @@ export class Input implements ComponentInterface { private inheritedAttributes: Attributes = {}; private isComposing = false; private legacyFormController!: LegacyFormController; - private notchSpacerEl: HTMLElement | undefined; - + private slotMutationController?: SlotMutationController; private notchController?: NotchController; + private notchSpacerEl: HTMLElement | undefined; // This flag ensures we log the deprecation warning at most once. private hasLoggedDeprecationWarning = false; @@ -362,6 +364,7 @@ export class Input implements ComponentInterface { const { el } = this; this.legacyFormController = createLegacyFormController(el); + this.slotMutationController = createSlotMutationController(el, 'label', () => forceUpdate(this)); this.notchController = createNotchController( el, () => this.notchSpacerEl, @@ -396,6 +399,11 @@ export class Input implements ComponentInterface { ); } + if (this.slotMutationController) { + this.slotMutationController.destroy(); + this.slotMutationController = undefined; + } + if (this.notchController) { this.notchController.destroy(); this.notchController = undefined; @@ -651,7 +659,12 @@ export class Input implements ComponentInterface { return [