Skip to content

Commit 4c54cf7

Browse files
committed
Fix ionic-team#28665: do not float label because of slotted items
1 parent be7561d commit 4c54cf7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: core/src/components/input/input.scss

+7
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,13 @@
593593
max-width: calc(100% / #{$form-control-label-stacked-scale});
594594
}
595595

596+
/**
597+
* This removes the slotted items on floating label when empty and no focus.
598+
*/
599+
:host(.input-label-placement-floating:not(.has-focus):not(.has-value)) .native-wrapper > [slot] {
600+
display: none;
601+
}
602+
596603
// Start/End Slots
597604
// ----------------------------------------------------------------
598605

Diff for: core/src/components/input/input.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ export class Input implements ComponentInterface {
689689
}
690690

691691
render() {
692-
const { disabled, fill, readonly, shape, inputId, labelPlacement, el, hasFocus, clearInputIcon } = this;
692+
const { disabled, fill, readonly, shape, inputId, labelPlacement, hasFocus, clearInputIcon } = this;
693693
const mode = getIonMode(this);
694694
const value = this.getValue();
695695
const inItem = hostContext('ion-item', this.el);
@@ -698,7 +698,6 @@ export class Input implements ComponentInterface {
698698
const clearIconData = clearInputIcon ?? defaultClearIcon;
699699

700700
const hasValue = this.hasValue();
701-
const hasStartEndSlots = el.querySelector('[slot="start"], [slot="end"]') !== null;
702701

703702
/**
704703
* If the label is stacked, it should always sit above the input.
@@ -714,11 +713,9 @@ export class Input implements ComponentInterface {
714713
* other when the label isn't floating above the input. This doesn't
715714
* apply to the outline fill, but this was not accounted for to keep
716715
* things consistent.
717-
*
718-
* TODO(FW-5592): Remove hasStartEndSlots condition
719716
*/
720717
const labelShouldFloat =
721-
labelPlacement === 'stacked' || (labelPlacement === 'floating' && (hasValue || hasFocus || hasStartEndSlots));
718+
labelPlacement === 'stacked' || (labelPlacement === 'floating' && (hasValue || hasFocus));
722719

723720
return (
724721
<Host

0 commit comments

Comments
 (0)