Skip to content

Commit 42ca99d

Browse files
committed
fix(select): apply proper styles for stacked/floating selects
adds padding attributes to select to style the correct padding with a stacked/floating label fixes #15140 references #14850
1 parent 39104cb commit 42ca99d

File tree

6 files changed

+44
-25
lines changed

6 files changed

+44
-25
lines changed

core/src/components/item/item.scss

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -157,46 +157,48 @@ button, a {
157157
}
158158

159159

160-
// FROM LABEL
160+
// Item Input
161+
// -----------------------------------------
162+
161163
:host(.item-label-stacked) .input-wrapper,
162164
:host(.item-label-floating) .input-wrapper {
163165
flex: 1;
164166
flex-direction: column;
165167
}
166168

167-
:host(.item-label-stacked)::slotted(ion-select),
168-
:host(.item-label-floating)::slotted(ion-select) {
169-
align-self: stretch;
170-
171-
max-width: 100%;
172-
}
173-
174-
175-
176-
177-
// TODO: FROM textarea
178-
179-
:host(.item-textarea) {
180-
align-items: stretch;
181-
}
182-
183169
// :host(.item-input-has-focus) a,
184170
// :host(.item-input-has-focus) button,
185171
// :host(.item-input-has-focus) textarea {
186172
// pointer-events: auto;
187173
// }
188174

189175

190-
// FROM SELECT
191-
:host(.item-multiple-inputs) ::slotted(ion-select) {
192-
position: relative;
193-
}
176+
// Item Select
177+
// -----------------------------------------
194178

195179
:host(.item-label-stacked) ::slotted(ion-select),
196180
:host(.item-label-floating) ::slotted(ion-select) {
181+
align-self: stretch;
182+
197183
max-width: 100%;
184+
width: 100%;
185+
186+
--padding-start: 0;
187+
}
188+
189+
:host(.item-multiple-inputs) ::slotted(ion-select) {
190+
position: relative;
191+
}
192+
193+
194+
// Item Textarea
195+
// -----------------------------------------
196+
197+
:host(.item-textarea) {
198+
align-items: stretch;
198199
}
199200

201+
200202
// Item Reorder
201203
// --------------------------------------------------
202204

core/src/components/select/select.ios.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// --------------------------------------------------
66

77
:host {
8-
@include padding($select-ios-padding-top, $select-ios-padding-end, $select-ios-padding-bottom, $select-ios-padding-start);
8+
--padding-top: #{$select-ios-padding-top};
9+
--padding-end: #{$select-ios-padding-end};
10+
--padding-bottom: #{$select-ios-padding-bottom};
11+
--padding-start: #{$select-ios-padding-start};
912

1013
color: $select-ios-text-color;
1114

core/src/components/select/select.md.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// --------------------------------------------------
66

77
:host {
8-
@include padding($select-md-padding-top, $select-md-padding-end, $select-md-padding-bottom, $select-md-padding-start);
8+
--padding-top: #{$select-md-padding-top};
9+
--padding-end: #{$select-md-padding-end};
10+
--padding-bottom: #{$select-md-padding-bottom};
11+
--padding-start: #{$select-md-padding-start};
912

1013
color: $select-md-text-color;
1114

core/src/components/select/select.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// --------------------------------------------------
55

66
:host {
7+
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
8+
79
display: flex;
810

911
overflow: hidden;

core/src/components/select/select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export class Select {
443443
this.ionStyle.emit({
444444
'interactive': true,
445445
'select': true,
446-
'input-has-value': this.hasValue(),
446+
'has-value': this.hasValue(),
447447
'interactive-disabled': this.disabled,
448448
'select-disabled': this.disabled
449449
});

core/src/components/select/test/basic/index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@
223223
</ion-select>
224224
</ion-item>
225225

226+
<ion-item>
227+
<ion-label position="stacked">Stacked: selected</ion-label>
228+
<ion-select>
229+
<ion-select-option>Default</ion-select-option>
230+
<ion-select-option selected>Other</ion-select-option>
231+
<ion-select-option>N/A</ion-select-option>
232+
</ion-select>
233+
</ion-item>
234+
226235
<ion-item>
227236
<ion-label position="floating">Floating</ion-label>
228237
<ion-select>
@@ -233,7 +242,7 @@
233242
</ion-item>
234243

235244
<ion-item>
236-
<ion-label position="floating">Floating</ion-label>
245+
<ion-label position="floating">Floating: selected</ion-label>
237246
<ion-select>
238247
<ion-select-option selected="true">Default</ion-select-option>
239248
<ion-select-option>Other</ion-select-option>

0 commit comments

Comments
 (0)