fix(select): hide notch cutout if no visible label provided (#27649)

This commit is contained in:
Liam DeBeasi
2023-06-15 09:01:46 -04:00
committed by GitHub
parent d44422e224
commit 606a892e40
3 changed files with 21 additions and 2 deletions

View File

@ -316,7 +316,8 @@ button {
* then the element should be hidden otherwise * then the element should be hidden otherwise
* there will be additional margins added. * there will be additional margins added.
*/ */
.label-text-wrapper-hidden { .label-text-wrapper-hidden,
.select-outline-notch-hidden {
display: none; display: none;
} }

View File

@ -910,7 +910,12 @@ export class Select implements ComponentInterface {
return [ return [
<div class="select-outline-container"> <div class="select-outline-container">
<div class="select-outline-start"></div> <div class="select-outline-start"></div>
<div class="select-outline-notch"> <div
class={{
'select-outline-notch': true,
'select-outline-notch-hidden': !this.hasLabel,
}}
>
<div class="notch-spacer" aria-hidden="true" ref={(el) => (this.notchSpacerEl = el)}> <div class="notch-spacer" aria-hidden="true" ref={(el) => (this.notchSpacerEl = el)}>
{this.label} {this.label}
</div> </div>

View File

@ -224,4 +224,17 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
expect(await select.screenshot()).toMatchSnapshot(screenshot(`select-fill-outline-hidden-slotted-label`)); expect(await select.screenshot()).toMatchSnapshot(screenshot(`select-fill-outline-hidden-slotted-label`));
}); });
}); });
test.describe(title('select: notch cutout'), () => {
test('notch cutout should be hidden when no label is passed', async ({ page }) => {
await page.setContent(
`
<ion-select fill="outline" label-placement="stacked" aria-label="my select"></ion-select>
`,
config
);
const notchCutout = page.locator('ion-select .select-outline-notch');
await expect(notchCutout).toBeHidden();
});
});
}); });