Skip to content

Commit 921bfae

Browse files
fix(select): floating label covers placeholder when when blurred (#27446)
Issue number: resolves #27201 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Selects with a floating label, no value, and a placeholder should have the label cover the placeholder when blurred. One focus, the label should translate to the top of the select, and the placeholder should be visible. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Floating label now covers the select and hides the placeholder when the select is blurred, matching the `ion-input` and `ion-textarea` behaviors. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: ionitron <[email protected]>
1 parent 7b7e05a commit 921bfae

File tree

26 files changed

+28
-6
lines changed

26 files changed

+28
-6
lines changed

core/src/components/select/select.scss

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ button {
227227
box-sizing: border-box;
228228
}
229229

230+
.select-wrapper .select-placeholder {
231+
/**
232+
* When the floating label appears on top of the
233+
* select, we need to fade the text out so that the
234+
* label does not overlap with the placeholder.
235+
*/
236+
transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
237+
}
238+
230239
// Select Highlight
231240
// ----------------------------------------------------------------
232241

@@ -473,16 +482,17 @@ button {
473482
}
474483

475484
/**
476-
* The select should be hidden when the label
485+
* The placeholder should be hidden when the label
477486
* is on top of the select. This prevents the label
478487
* from overlapping any placeholder value.
479488
*/
480-
:host(.select-label-placement-floating:not(.has-placeholder)) .native-wrapper .select-text {
489+
:host(.select-label-placement-floating) .native-wrapper .select-placeholder {
481490
opacity: 0;
482491
}
483492

484-
:host(.select-expanded.select-label-placement-floating) .native-wrapper .select-text,
485-
:host(.has-value.select-label-placement-floating) .native-wrapper .select-text {
493+
:host(.select-expanded.select-label-placement-floating) .native-wrapper .select-placeholder,
494+
:host(.ion-focused.select-label-placement-floating) .native-wrapper .select-placeholder,
495+
:host(.has-value.select-label-placement-floating) .native-wrapper .select-placeholder {
486496
opacity: 1;
487497
}
488498

@@ -492,8 +502,7 @@ button {
492502
:host(.select-label-placement-stacked) .label-text-wrapper,
493503
:host(.select-expanded.select-label-placement-floating) .label-text-wrapper,
494504
:host(.ion-focused.select-label-placement-floating) .label-text-wrapper,
495-
:host(.has-value.select-label-placement-floating) .label-text-wrapper,
496-
:host(.has-placeholder.select-label-placement-floating) .label-text-wrapper {
505+
:host(.has-value.select-label-placement-floating) .label-text-wrapper {
497506
@include transform(translateY(50%), scale(#{$select-floating-label-scale}));
498507

499508
/**

core/src/components/textarea/test/label-placement/textarea.e2e.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ configs().forEach(({ title, screenshot, config }) => {
179179
const textarea = page.locator('ion-textarea');
180180
expect(await textarea.screenshot()).toMatchSnapshot(screenshot(`textarea-placement-floating-no-value`));
181181
});
182+
test('label should appear on top of the textarea when there is a placeholder and no value', async ({ page }) => {
183+
await page.setContent(
184+
`
185+
<ion-textarea label="Standard" label-placement="floating" placeholder="Placeholder"></ion-textarea>
186+
`,
187+
config
188+
);
189+
190+
const textarea = page.locator('ion-textarea');
191+
expect(await textarea.screenshot()).toMatchSnapshot(
192+
screenshot(`textarea-placement-floating-no-value-placeholder`)
193+
);
194+
});
182195
test('label should appear on top of the textarea when the textarea is focused', async ({ page }) => {
183196
await page.setContent(
184197
`

0 commit comments

Comments
 (0)