Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(select): ensure select sizes are respected when the label is empty #30087

Merged
merged 7 commits into from
Dec 20, 2024
Merged
21 changes: 0 additions & 21 deletions core/src/components/select/select.common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@
cursor: pointer;
}

/**
* Since the label sits on top of the element,
* the component needs to be taller otherwise the
* label will appear too close to the select text.
*/
:host(.select-label-placement-floating),
:host(.select-label-placement-stacked) {
min-height: 56px;
}

:host(.ion-color) {
--highlight-color-focused: #{current-color(base)};
}
Expand Down Expand Up @@ -221,17 +211,6 @@ button {
overflow: hidden;
}

:host(.select-label-placement-stacked) .select-wrapper-inner,
:host(.select-label-placement-floating) .select-wrapper-inner {
/**
* When using a stacked/floating label, the inner wrapper is
* stacked vertically under the label container. This line
* ensures that the inner wrapper fills all the remaining height
* of the component.
*/
flex-grow: 1;
}

// Select Highlight
// ----------------------------------------------------------------

Expand Down
21 changes: 21 additions & 0 deletions core/src/components/select/select.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@
max-width: calc(100% / #{$form-control-label-stacked-scale});
}

/**
* Since the label sits on top of the element,
* the component needs to be taller otherwise the
* label will appear too close to the select text.
*/
:host(.select-label-placement-floating),
:host(.select-label-placement-stacked) {
min-height: 56px;
}

/**
* When using a stacked/floating label, the inner wrapper is
* stacked vertically under the label container. This line
* ensures that the inner wrapper fills all the remaining height
* of the component.
*/
:host(.select-label-placement-stacked) .select-wrapper-inner,
:host(.select-label-placement-floating) .select-wrapper-inner {
flex-grow: 1;
}

// Start/End Slots
// ----------------------------------------------------------------

Expand Down
9 changes: 9 additions & 0 deletions core/src/components/select/test/size/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,29 @@ <h2>Small</h2>
<ion-select size="small" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
<ion-select size="small" fill="outline" label="" label-placement="stacked" value="filledText2">
<ion-select-option value="filledText2">Filled text</ion-select-option>
</ion-select>
</div>

<div class="grid-item">
<h2>Medium</h2>
<ion-select size="medium" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
<ion-select size="medium" fill="outline" label="" label-placement="stacked" value="filledText2">
<ion-select-option value="filledText2">Filled text</ion-select-option>
</ion-select>
</div>

<div class="grid-item">
<h2>Large</h2>
<ion-select size="large" fill="outline" label="Label" label-placement="stacked" value="filledText">
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
<ion-select size="large" fill="outline" label="" label-placement="stacked" value="filledText2">
<ion-select-option value="filledText2">Filled text</ion-select-option>
</ion-select>
</div>
</div>
</ion-content>
Expand Down
20 changes: 20 additions & 0 deletions core/src/components/select/test/size/select.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ config, screens

await expect(select).toHaveScreenshot(screenshot(`select-size-${size}`));
});

test(`${size} - should not have visual regressions when label is unset`, async ({ page }) => {
await page.setContent(
`
<ion-select
size="${size}"
fill="outline"
label-placement="stacked"
value="filledText"
>
<ion-select-option value="filledText">Filled text</ion-select-option>
</ion-select>
`,
config
);

const select = page.locator('ion-select');

await expect(select).toHaveScreenshot(screenshot(`select-size-${size}-unset-label`));
});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading