Skip to content

Commit 9a9568c

Browse files
authored
fix(input): item and clear input styling is correct (#26238)
1 parent 73a8826 commit 9a9568c

File tree

126 files changed

+420
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+420
-228
lines changed

core/src/components/input/input.ios.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
font-size: $input-ios-font-size;
99
}
1010

11+
// TODO FW-2764 Remove this
1112
:host(.legacy-input) {
1213
--padding-top: #{$input-ios-padding-top};
1314
--padding-end: #{$input-ios-padding-end};

core/src/components/input/input.md.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@import "./input.md.vars";
33
@import "./input.md.solid.scss";
44
@import "./input.md.outline.scss";
5+
@import "../item/item.md.vars.scss";
56

67
// Material Design Input
78
// --------------------------------------------------
@@ -13,6 +14,7 @@
1314
font-size: $input-md-font-size;
1415
}
1516

17+
// TODO FW-2764 Remove this
1618
:host(.legacy-input) {
1719
--padding-top: #{$input-md-padding-top};
1820
--padding-end: #{$input-md-padding-end};
@@ -36,6 +38,16 @@
3638
background-size: $input-md-input-clear-icon-size;
3739
}
3840

41+
/**
42+
* The input with no fill in item should
43+
* have start padding applied on the input
44+
* not the item.
45+
*/
46+
:host(.in-full-item:not(.input-fill-outline)),
47+
:host(.in-full-item:not(.input-fill-solid)) {
48+
--padding-start: #{$item-md-padding-start};
49+
}
50+
3951
// Input Bottom
4052
// ----------------------------------------------------------------
4153
/**

core/src/components/input/input.scss

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
z-index: $z-index-item-input;
6868
}
6969

70+
// TODO FW-2764 Remove this
7071
:host(.legacy-input) {
7172
display: flex;
7273

@@ -76,15 +77,17 @@
7677
background: var(--background);
7778
}
7879

80+
// TODO FW-2764 Remove this
7981
:host(.legacy-input) .native-input {
8082
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
8183
@include border-radius(var(--border-radius));
8284
}
8385

84-
:host-context(ion-item:not(.item-label)) {
86+
:host-context(ion-item:not(.item-label):not(.item-has-modern-input)) {
8587
--padding-start: 0;
8688
}
8789

90+
// TODO FW-2764 Remove this
8891
:host(.legacy-input.ion-color) {
8992
color: current-color(base);
9093
}
@@ -180,8 +183,13 @@
180183
// Clear Input Icon
181184
// --------------------------------------------------
182185

183-
.input-clear-icon {
186+
// TODO FW-2764 Remove this
187+
:host(.legacy-input) .input-clear-icon {
184188
@include margin(0);
189+
}
190+
191+
.input-clear-icon {
192+
@include margin(auto);
185193
@include padding(0);
186194
@include background-position(center);
187195

@@ -263,6 +271,17 @@
263271
background: var(--background);
264272
}
265273

274+
// Input Native Wrapper
275+
// ----------------------------------------------------------------
276+
277+
.native-wrapper {
278+
display: flex;
279+
280+
flex-grow: 1;
281+
282+
width: 100%;
283+
}
284+
266285
// Input Highlight
267286
// ----------------------------------------------------------------
268287

core/src/components/input/input.tsx

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
} from '../../interface';
1616
import type { Attributes } from '../../utils/helpers';
1717
import { inheritAriaAttributes, debounceEvent, findItemLabel, inheritAttributes } from '../../utils/helpers';
18-
import { createColorClasses } from '../../utils/theme';
18+
import { createColorClasses, hostContext } from '../../utils/theme';
1919

2020
import { getCounterText } from './input.utils';
2121

@@ -616,67 +616,71 @@ export class Input implements ComponentInterface {
616616
[`input-fill-${fill}`]: fill !== undefined,
617617
[`input-shape-${shape}`]: shape !== undefined,
618618
[`input-label-placement-${labelPlacement}`]: true,
619+
'in-full-item': hostContext('ion-item:not(.item-lines-inset)', this.el),
619620
})}
620621
>
621622
<div class="input-wrapper">
622623
{this.renderLabelContainer()}
623-
<input
624-
class="native-input"
625-
ref={(input) => (this.nativeInput = input)}
626-
id={inputId}
627-
disabled={disabled}
628-
accept={this.accept}
629-
autoCapitalize={this.autocapitalize}
630-
autoComplete={this.autocomplete}
631-
autoCorrect={this.autocorrect}
632-
autoFocus={this.autofocus}
633-
enterKeyHint={this.enterkeyhint}
634-
inputMode={this.inputmode}
635-
min={this.min}
636-
max={this.max}
637-
minLength={this.minlength}
638-
maxLength={this.maxlength}
639-
multiple={this.multiple}
640-
name={this.name}
641-
pattern={this.pattern}
642-
placeholder={this.placeholder || ''}
643-
readOnly={readonly}
644-
required={this.required}
645-
spellcheck={this.spellcheck}
646-
step={this.step}
647-
size={this.size}
648-
type={this.type}
649-
value={value}
650-
onInput={this.onInput}
651-
onChange={this.onChange}
652-
onBlur={this.onBlur}
653-
onFocus={this.onFocus}
654-
onKeyDown={this.onKeydown}
655-
{...this.inheritedAttributes}
656-
/>
657-
{this.clearInput && !readonly && !disabled && (
658-
<button
659-
aria-label="reset"
660-
type="button"
661-
class="input-clear-icon"
662-
onPointerDown={(ev) => {
663-
/**
664-
* This prevents mobile browsers from
665-
* blurring the input when the clear
666-
* button is activated.
667-
*/
668-
ev.preventDefault();
669-
}}
670-
onClick={this.onClearButtonClick}
624+
<div class="native-wrapper">
625+
<input
626+
class="native-input"
627+
ref={(input) => (this.nativeInput = input)}
628+
id={inputId}
629+
disabled={disabled}
630+
accept={this.accept}
631+
autoCapitalize={this.autocapitalize}
632+
autoComplete={this.autocomplete}
633+
autoCorrect={this.autocorrect}
634+
autoFocus={this.autofocus}
635+
enterKeyHint={this.enterkeyhint}
636+
inputMode={this.inputmode}
637+
min={this.min}
638+
max={this.max}
639+
minLength={this.minlength}
640+
maxLength={this.maxlength}
641+
multiple={this.multiple}
642+
name={this.name}
643+
pattern={this.pattern}
644+
placeholder={this.placeholder || ''}
645+
readOnly={readonly}
646+
required={this.required}
647+
spellcheck={this.spellcheck}
648+
step={this.step}
649+
size={this.size}
650+
type={this.type}
651+
value={value}
652+
onInput={this.onInput}
653+
onChange={this.onChange}
654+
onBlur={this.onBlur}
655+
onFocus={this.onFocus}
656+
onKeyDown={this.onKeydown}
657+
{...this.inheritedAttributes}
671658
/>
672-
)}
659+
{this.clearInput && !readonly && !disabled && (
660+
<button
661+
aria-label="reset"
662+
type="button"
663+
class="input-clear-icon"
664+
onPointerDown={(ev) => {
665+
/**
666+
* This prevents mobile browsers from
667+
* blurring the input when the clear
668+
* button is activated.
669+
*/
670+
ev.preventDefault();
671+
}}
672+
onClick={this.onClearButtonClick}
673+
/>
674+
)}
675+
</div>
673676
{shouldRenderHighlight && <div class="input-highlight"></div>}
674677
</div>
675678
{this.renderBottomContent()}
676679
</Host>
677680
);
678681
}
679682

683+
// TODO FW-2764 Remove this
680684
private renderLegacyInput() {
681685
if (!this.hasLoggedDeprecationWarning) {
682686
printIonWarning(

0 commit comments

Comments
 (0)