fix(select): update default inital styling of required selects#2311
fix(select): update default inital styling of required selects#2311
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Select component’s “invalid” styling behavior so required selects don’t show error styling on initial render, aligning visual validation with user interaction.
Changes:
- Replace
:invalidselectors with:user-invalidin select field CSS to prevent initial error styling. - Add screenshot coverage for
Selectwithrequiredin both light and dark themes. - Add new baseline snapshots for the required-select screenshots.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/styles/select.css | Switches invalid-state styling from :invalid to :user-invalid to avoid showing errors before user interaction. |
| packages/react/src/components/Select/screenshots.e2e.tsx | Adds Playwright component screenshot test for Select[required] (light/dark). |
| e2e/screenshots/select-required-.png | New baseline snapshot for required select (light theme). |
| e2e/screenshots/dark--select-required-.png | New baseline snapshot for required select (dark theme). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
|
The CSS fix ( However, the "after interaction" e2e test (lines 88-91 in await component.getByLabel('Select').focus();
await component.getByLabel('Select').blur();This is not sufficient to trigger To properly trigger const select = component.getByLabel('Select');
await select.selectOption('apple'); // select a valid value
await select.selectOption(''); // change back to invalid
await select.blur();This would produce a screenshot that actually demonstrates the error styling appearing after user interaction, fully proving the fix works in both directions. |
Addressed! More screenshots than expected were updated, however, my guess is it is from modal scrolling.
anastasialanz
left a comment
There was a problem hiding this comment.
The screenshots still don't seem right because the red outline is missing for the "after" screenshot. I tried the code out below and was able to generate the error styles. Let me know if it works for you.
da32610 to
07822cf
Compare
Pull request was closed
Summary
Fixes #1532
select.cssfrom:invalidto:user-invalidso that required select fields no longer display error styling (red ring) on initial page load:user-invalidonly activates after the user has interacted with the field or submitted the form, matching expected behaviorSelect[required]with light and dark theme snapshotsTest plan
errorprop styling is unaffected