refactor: Validation stack refactor and SSR support#2261
Merged
Conversation
- Refactor validation stack to support SSR and simplify the logic for determining the validation state of the component. This includes changes to the way validation messages are collected and rendered, as well as updates to the associated mixins and controllers. - Updated mutation observer and slot controllers to better handle SSR scenarios.
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the validation container/stack to improve determinism and add SSR safety guards across validation rendering, slot handling, and mutation observation, aiming to reduce hydration mismatches and simplify validation state logic.
Changes:
- Refactors
igc-validatorto render validation message slots deterministically and to better align initial render output for SSR/hydration. - Adds SSR guards to slot and mutation observer controllers to avoid DOM access on the server.
- Updates the form-associated mixin’s validation cycle bookkeeping and adds SSR short-circuiting for
_validate().
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/components/validation-container/validation-container.ts |
Reworks validation slot/message rendering and projection collection with SSR/hydration considerations. |
src/components/common/mixins/forms/associated.ts |
Adjusts validation-cycle flags/flow and avoids running _validate() on the server. |
src/components/common/controllers/slot.ts |
Adds SSR guard for slot querying and fixes selector quoting for named slots. |
src/components/common/controllers/mutation-observer.ts |
Makes the observer optional and skips MutationObserver setup on the server. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactor validation stack to support SSR and simplify the logic for determining the validation state of the component.
This includes changes to the way validation messages are collected and rendered, as well as updates to the
associated mixins and controllers.
Updated mutation observer and slot controllers to better handle SSR scenarios.
Type of Change
Checklist