Skip to content

fix(validator): project validation messages for a host that starts invalid - #2374

Merged
rkaraivanov merged 1 commit into
masterfrom
rkaraivanov/validator-fixes
Sep 3, 2026
Merged

fix(validator): project validation messages for a host that starts invalid#2374
rkaraivanov merged 1 commit into
masterfrom
rkaraivanov/validator-fixes

Conversation

@rkaraivanov

Copy link
Copy Markdown
Member

Description

The container's first render is neutral for SSR parity and create skips the light DOM projection slots until the host has updated. A host that hydrated invalid (<igc-input required invalid>) never re-rendered, so its validation messages stayed hidden. The container now asks the host for a follow-up render from firstUpdated when it is invalid.

Also:

  • cache kebab-cased slot names at module load instead of per render
  • take the projected-slot set in _renderHelper and make the render helpers private
  • tighten comments and the target docs; the ?invalid note wrongly claimed the internal events cover failed submissions
  • add specs for the initially invalid host and the create() config

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Refactoring (code improvements without functional changes)

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally

…valid

The container's first render is neutral for SSR parity and `create` skips
the light DOM projection slots until the host has updated. A host that
hydrated invalid (`<igc-input required invalid>`) never re-rendered, so
its validation messages stayed hidden. The container now asks the host
for a follow-up render from `firstUpdated` when it is invalid.

Also:
- cache kebab-cased slot names at module load instead of per render
- take the projected-slot set in `_renderHelper` and make the render
  helpers private
- tighten comments and the `target` docs; the `?invalid` note wrongly
  claimed the internal events cover failed submissions
- add specs for the initially invalid host and the `create()` config
Copilot AI lite review requested due to automatic review settings September 3, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

create() currently treats an omitted hasHelperText as false (disabling helper text when config is provided), and the updated spec should include the required accessibility audit assertions to match project testing conventions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes a hydration/SSR-parity edge case where a form control that starts out invalid never triggers the follow-up host render needed for projecting validation-message slots, leaving validation messages hidden. The container now prompts a host re-render from firstUpdated when starting invalid, and the PR also refactors slot-name handling and expands specs around initial-invalid and create() configuration behavior.

Changes:

  • Request a follow-up host render from the container’s firstUpdated() when the host hydrates invalid so validation slots can be projected.
  • Refactor validation slot name generation by caching kebab-cased slot names at module load and tightening internal helper APIs.
  • Add/extend specs for the “initially invalid host” case and create() configuration behavior.
File summaries
File Description
src/components/validation-container/validation-container.ts Updates slot generation and lifecycle behavior to ensure projected validation messages appear when the host starts invalid.
src/components/validation-container/validation-container.spec.ts Adds coverage for initially-invalid hosts and create() config scenarios (with suggested additions for a11y + default helper slot behavior).
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 99 to 101
const helperText = config.hasHelperText
? html`<slot name="helper-text" slot="helper-text"></slot>`
: nothing;
Comment on lines +138 to +143
it('projects a helper-text slot by default', async () => {
const container = await createContainer();

expect(container.id).to.equal(helperSlot);
expect(container.querySelector(projectedHelperSlot)).not.to.be.null;
});
Comment on lines +152 to +162
it('applies the id, slot and part from the configuration', async () => {
const container = await createContainer({
id: 'custom-id',
slot: 'anchor',
part: 'custom-part',
});

expect(container.id).to.equal('custom-id');
expect(container.slot).to.equal('anchor');
expect(container.part.contains('custom-part')).to.be.true;
});
@rkaraivanov
rkaraivanov merged commit a565209 into master Sep 3, 2026
8 checks passed
@rkaraivanov
rkaraivanov deleted the rkaraivanov/validator-fixes branch September 3, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants