diff --git a/core/src/components/input/input.scss b/core/src/components/input/input.scss index e24bf990eb9..f5d02058228 100644 --- a/core/src/components/input/input.scss +++ b/core/src/components/input/input.scss @@ -106,6 +106,13 @@ flex: 1; width: 100%; + + /** + * The input keeps a minimum width so that the value stays visible + * when a long label or wide slotted content would otherwise shrink + * it to nothing. + */ + min-width: $form-control-min-width; max-width: 100%; // Ensure the input fills the full height of the native wrapper. diff --git a/core/src/components/input/test/slot/input.e2e.ts b/core/src/components/input/test/slot/input.e2e.ts index e22e795c768..a63785c06e3 100644 --- a/core/src/components/input/test/slot/input.e2e.ts +++ b/core/src/components/input/test/slot/input.e2e.ts @@ -299,6 +299,47 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co screenshot(`input-slot-overflow-label-floating-value-${slotName}-slot`) ); }); + + /** + * The label and the input compete for whatever space the slot leaves + * behind. The input has to keep some of it so that the user can still + * see the value they are entering. + */ + test(`should not have visual regressions with a start-positioned label, a value and a wide ${slotName} slot`, async ({ + page, + }) => { + await setContent(page, 'label-placement="start" value="100"', slot); + + const container = page.locator('.container'); + await expect(container).toHaveScreenshot(screenshot(`input-slot-overflow-label-start-value-${slotName}-slot`)); + }); + + test(`should keep two characters of the value visible with a start-positioned label and a wide ${slotName} slot`, async ({ + page, + }) => { + await setContent(page, 'label-placement="start" value="100"', slot); + + const nativeInput = page.locator('ion-input input'); + + /** + * The width of two characters in the input's own font, which is what + * `$form-control-min-width` reserves for the value. + */ + const twoCharacterWidth = await nativeInput.evaluate((el) => { + const probe = document.createElement('span'); + probe.style.cssText = `position: absolute; visibility: hidden; white-space: pre; font: ${ + getComputedStyle(el).font + }`; + probe.textContent = '00'; + document.body.append(probe); + const { width } = probe.getBoundingClientRect(); + probe.remove(); + return width; + }); + const box = await nativeInput.boundingBox(); + + expect(box!.width).toBeGreaterThanOrEqual(twoCharacterWidth); + }); }); }); }); diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png index 5c17032d0da..91a2cef6d8f 100644 Binary files a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png index a08604737c8..0b5bea23e9f 100644 Binary files a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png index 4f300336cf5..f397b3e70eb 100644 Binary files a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png index 940a247cee0..faa683a84dc 100644 Binary files a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png index 51f54378272..eb1aea69640 100644 Binary files a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png index b025d8c9f11..57b333e8a89 100644 Binary files a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..64dc04bb198 Binary files /dev/null and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..2868ea41277 Binary files /dev/null and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Safari-linux.png new file mode 100644 index 00000000000..5c63e43eba4 Binary files /dev/null and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..dba097a6145 Binary files /dev/null and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..af7d68dc5b2 Binary files /dev/null and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Safari-linux.png new file mode 100644 index 00000000000..7cb78643e1f Binary files /dev/null and b/core/src/components/input/test/slot/input.e2e.ts-snapshots/input-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Chrome-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Chrome-linux.png index ac2eb8be127..bab3160187e 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Chrome-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Firefox-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Firefox-linux.png index d843bde11be..47078130b85 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Firefox-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Safari-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Safari-linux.png index f18894350bf..dd5eed9b793 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Safari-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Chrome-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Chrome-linux.png index dbd9f21ddf9..f4744f5a4d0 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Chrome-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Chrome-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Firefox-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Firefox-linux.png index aa387c7f934..e4c0ab8c769 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Firefox-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Firefox-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Safari-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Safari-linux.png index c894a066f40..8e308b6db2e 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Safari-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-rtl-Mobile-Safari-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Chrome-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Chrome-linux.png index 198338daba3..d985c1a06d0 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Firefox-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Firefox-linux.png index 0ef707e079a..e11eb2f9415 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Safari-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Safari-linux.png index 130f37b511b..622ced1c97c 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Safari-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Chrome-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Chrome-linux.png index 0d8b6331954..d7bd849bf6c 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Chrome-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Chrome-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Firefox-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Firefox-linux.png index 0903054ec7b..2abb49d033b 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Firefox-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Firefox-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Safari-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Safari-linux.png index 95f7000e1be..d68bcc43887 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Safari-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-md-rtl-Mobile-Safari-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Chrome-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Chrome-linux.png index 4fbca6ec1b4..35ed98c1d0a 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Chrome-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Firefox-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Firefox-linux.png index 69dc9c6fab3..43d06761556 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Firefox-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Safari-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Safari-linux.png index 42ba5871969..d754ce166ce 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Safari-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-ios-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Chrome-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Chrome-linux.png index fc4404242a4..3b3a5540e6e 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Firefox-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Firefox-linux.png index 081d6371781..90d1142361b 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Safari-linux.png b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Safari-linux.png index 914568c6e26..a50b10d5bac 100644 Binary files a/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Safari-linux.png and b/core/src/components/item/test/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-select-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/select/select.scss b/core/src/components/select/select.scss index 38614c46804..a15be099615 100644 --- a/core/src/components/select/select.scss +++ b/core/src/components/select/select.scss @@ -159,7 +159,7 @@ button { .select-text { flex: 1; - min-width: 16px; + min-width: $form-control-min-width; font-size: inherit; diff --git a/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Chrome-linux.png b/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Chrome-linux.png index dded6cb77f2..cc77ba5f3d1 100644 Binary files a/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Firefox-linux.png b/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Firefox-linux.png index 98aed59c1c8..7d7a3a87a8c 100644 Binary files a/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Safari-linux.png b/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Safari-linux.png index 02d43062d18..a84886fe248 100644 Binary files a/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Safari-linux.png and b/core/src/components/select/test/fill/select.e2e.ts-snapshots/select-fill-outline-fit-content-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/select/test/slot/select.e2e.ts b/core/src/components/select/test/slot/select.e2e.ts index 7b8b5d9b3cc..2b894f6e159 100644 --- a/core/src/components/select/test/slot/select.e2e.ts +++ b/core/src/components/select/test/slot/select.e2e.ts @@ -476,6 +476,44 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co screenshot(`select-slot-overflow-label-floating-value-${slotName}-slot`) ); }); + + // TODO(FW-7682): unskip once the selected text is no longer clipped away by .native-wrapper + test.skip(`should not have visual regressions with a start-positioned label, a value and a wide ${slotName} slot`, async ({ + page, + }) => { + await setContent(page, 'label-placement="start" value="100"', slot); + + const container = page.locator('.container'); + await expect(container).toHaveScreenshot(screenshot(`select-slot-overflow-label-start-value-${slotName}-slot`)); + }); + + // TODO(FW-7682): unskip once the selected text is no longer clipped away by .native-wrapper + test.skip(`should keep two characters of the value visible with a start-positioned label and a wide ${slotName} slot`, async ({ + page, + }) => { + await setContent(page, 'label-placement="start" value="100"', slot); + + const selectText = page.locator('ion-select .select-text'); + + /** + * The width of two characters in the selected text's own font, which + * is what `$form-control-min-width` reserves for the value. + */ + const twoCharacterWidth = await selectText.evaluate((el) => { + const probe = document.createElement('span'); + probe.style.cssText = `position: absolute; visibility: hidden; white-space: pre; font: ${ + getComputedStyle(el).font + }`; + probe.textContent = '00'; + document.body.append(probe); + const { width } = probe.getBoundingClientRect(); + probe.remove(); + return width; + }); + const box = await selectText.boundingBox(); + + expect(box!.width).toBeGreaterThanOrEqual(twoCharacterWidth); + }); }); }); }); diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts b/core/src/components/textarea/test/slot/textarea.e2e.ts index fc6494e414a..87c15eca153 100644 --- a/core/src/components/textarea/test/slot/textarea.e2e.ts +++ b/core/src/components/textarea/test/slot/textarea.e2e.ts @@ -299,6 +299,49 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co screenshot(`textarea-slot-overflow-label-floating-value-${slotName}-slot`) ); }); + + /** + * The label and the textarea compete for whatever space the slot leaves + * behind. The textarea has to keep some of it so that the user can still + * see the value they are entering. + */ + test(`should not have visual regressions with a start-positioned label, a value and a wide ${slotName} slot`, async ({ + page, + }) => { + await setContent(page, 'label-placement="start" value="100"', slot); + + const container = page.locator('.container'); + await expect(container).toHaveScreenshot( + screenshot(`textarea-slot-overflow-label-start-value-${slotName}-slot`) + ); + }); + + test(`should keep two characters of the value visible with a start-positioned label and a wide ${slotName} slot`, async ({ + page, + }) => { + await setContent(page, 'label-placement="start" value="100"', slot); + + const nativeTextarea = page.locator('ion-textarea textarea'); + + /** + * The width of two characters in the textarea's own font, which is + * what `$form-control-min-width` reserves for the value. + */ + const twoCharacterWidth = await nativeTextarea.evaluate((el) => { + const probe = document.createElement('span'); + probe.style.cssText = `position: absolute; visibility: hidden; white-space: pre; font: ${ + getComputedStyle(el).font + }`; + probe.textContent = '00'; + document.body.append(probe); + const { width } = probe.getBoundingClientRect(); + probe.remove(); + return width; + }); + const box = await nativeTextarea.boundingBox(); + + expect(box!.width).toBeGreaterThanOrEqual(twoCharacterWidth); + }); }); }); }); diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png index 7cf15578cac..2d425328765 100644 Binary files a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png index e4171f38e4b..76deec7853c 100644 Binary files a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png index a7677dd1286..bd0305517c2 100644 Binary files a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-end-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png index a9c8bcf3f77..9c411968922 100644 Binary files a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png index 3f7b46f082d..032556ede9f 100644 Binary files a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png index 2a194701b7d..5ce93dffe17 100644 Binary files a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-start-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..61dcb7f2062 Binary files /dev/null and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..ab792278b81 Binary files /dev/null and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Safari-linux.png new file mode 100644 index 00000000000..c761afabd6c Binary files /dev/null and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-end-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Chrome-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..83139caef4a Binary files /dev/null and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Firefox-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..45cb0a6f7b1 Binary files /dev/null and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Safari-linux.png b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Safari-linux.png new file mode 100644 index 00000000000..56d561e369f Binary files /dev/null and b/core/src/components/textarea/test/slot/textarea.e2e.ts-snapshots/textarea-slot-overflow-label-start-value-start-slot-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/textarea/textarea.scss b/core/src/components/textarea/textarea.scss index 9d749b30c19..7db3f21df17 100644 --- a/core/src/components/textarea/textarea.scss +++ b/core/src/components/textarea/textarea.scss @@ -119,6 +119,13 @@ flex: 1; width: 100%; + + /** + * The textarea keeps a minimum width so that the value stays visible + * when a long label or wide slotted content would otherwise shrink + * it to nothing. + */ + min-width: $form-control-min-width; max-width: 100%; max-height: 100%; @@ -305,7 +312,15 @@ .native-wrapper { display: grid; - min-width: inherit; + /** + * The wrapper has to carry the same minimum width as the textarea it holds. + * It is the flex item that competes with the label and the slots for space, + * so without it the textarea keeps its width but overflows the field. + * + * The minimum cannot be inherited because .textarea-control sets + * `min-width: 0` so that the slots keep their size. + */ + min-width: $form-control-min-width; max-width: inherit; min-height: inherit; max-height: inherit; diff --git a/core/src/themes/ionic.globals.scss b/core/src/themes/ionic.globals.scss index 6f281136fa2..1d5789607f1 100644 --- a/core/src/themes/ionic.globals.scss +++ b/core/src/themes/ionic.globals.scss @@ -39,6 +39,15 @@ $placeholder-opacity: var(--ion-placeholder-opacity, 0.6); $form-control-label-margin: 16px; +// The smallest width the editable area of a form control may shrink to. +// A long label or wide slotted content would otherwise consume the entire +// width and leave the user unable to see the value they are entering. +// Using `ch` keeps the same two characters visible as the text size grows. +// Characters wider than the `0` glyph can still clip. Widening the floor to +// fit them leaves too little room for the label, and typing scrolls the +// caret into view regardless. +$form-control-min-width: 2ch; + // How much the stacked labels should be scaled by /// The value 0.75 is used to match the MD spec. /// iOS does not have a floating label design spec, so we standardize on 0.75.