feat(validation): warn on invalid enum values instead of overriding - #6564
feat(validation): warn on invalid enum values instead of overriding#6564miwha-adobe wants to merge 1 commit into
Conversation
Proof-of-concept for the dev-warning fallback policy discussion. Removes the coerce-to-default behavior for constrained enums so an invalid value is left in place and a dev-mode warning is emitted, rather than being silently swapped for the default: - Tabs: keyboardActivation, density, direction (setters -> plain @Property + validateEnum in willUpdate) - AlertBanner: variant (setter no longer blanks/removes the attribute) - Meter: variant (drops the willUpdate this.variant = 'informative' fallback) Tests updated to assert the warn-only behavior. Attached to the fallback-vs-warn-only policy ticket for team review; not intended to merge until the policy is decided. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Description
This is a proof-of-concept, not intended to merge. It demonstrates removing the "coerce an invalid value to a default" behavior for constrained enums, so that an invalid value is left in place and a dev-mode warning is emitted instead of being silently swapped for the default. The purpose is to make the trade-offs concrete for a team discussion on what our fallback policy should be.
Changes shown here (for illustration only):
keyboardActivation,density,direction): coercing getter/setter pairs replaced with plain@property+validateEnuminwillUpdate(warn-only).variant): the setter no longer blanks or removes the attribute on invalid input.variant): drops thewillUpdatethis.variant = 'informative'fallback.The open question
When a consumer sets an invalid property value, should the component fall back to a default (and warn), or leave the value as-is (and warn)? Our components are currently inconsistent about this, and we want one deliberate, documented policy.
The tension comes down to production behavior, since dev warnings are stripped from production builds:
variant="banana"matches no CSS rule, so the component renders unstyled, with no warning). Fallback-to-default means it always looks like something, and developers still get told in dev.Proposed policy to discuss (not decided)
A consistent matrix, applied the same way everywhere, rather than per-component choices:
variant,size,density,direction)progress,level)Two things to note about how the current code sits against this proposal:
"Loading") when no accessible name is provided. Under the a11y exception that would become warn-only. This is the sharpest trade-off in the whole policy, because in production (no warning) it would ship an unnamed element to end users. It needs the most discussion and is not changed here.Relationship to the placement PR
The philosophy-neutral part of this effort (moving dev-warnings to the pre-render phase) is separated into its own PR and does not depend on this decision. That PR carries no behavior change. This branch carries only the contested coercion change.
Do not merge
Blocked on the fallback-policy decision. Attached to [Jira ticket number] for team discussion.