Skip to content

fix(web-components): make TextInput spellcheck null-safe - #36482

Draft
AKnassa wants to merge 1 commit into
microsoft:masterfrom
AKnassa:ak-issue-36462-spellcheck-null-converter
Draft

fix(web-components): make TextInput spellcheck null-safe#36482
AKnassa wants to merge 1 commit into
microsoft:masterfrom
AKnassa:ak-issue-36462-spellcheck-null-converter

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 1, 2026

Copy link
Copy Markdown

Previous Behavior

Setting the spellcheck property on <fluent-text-input> from JavaScript crashed the page with TypeError: Cannot read properties of null (reading 'toString'). This hit anyone using frameworks that set properties instead of attributes (React 19, Angular, Lit). On top of that, removing the spellcheck attribute silently broke the property forever — later writes just did nothing.

New Behavior

spellcheck works like you'd expect in every direction: set it to true/false from JS and the attribute reflects correctly, set it to null and the attribute is removed, remove the attribute and the property still works afterwards. Plain attribute usage (spellcheck="false" in HTML) behaves exactly as before.

What changed

  • The attribute converter in text-input.base.ts now handles booleans and null instead of assuming it always gets a string.
  • Four new Playwright tests cover the crash paths (they failed before the fix, pass after — verified in Chromium, Firefox, and WebKit, 225 tests total green).
  • A change file for the release notes.

How to verify

Before this fix, this one-liner crashes the page; now it works:

document.querySelector('fluent-text-input').spellcheck = false;

Related Issue(s)

The TextInput spellcheck attribute converter's toView called
value.toString() unconditionally. fast-element runs fromView for
property writes too, so any non-string write (el.spellcheck = true,
false, null, or undefined) stored null and the queued attribute
reflection crashed with 'Cannot read properties of null'. Removing
the attribute also left the field null, silently swallowing all
later boolean writes.

Handle booleans in fromView so property writes round-trip, and
return null from toView for nullish values so the attribute is
removed instead of throwing. Attribute-driven behavior (including
spellcheck="false" on the internal control) is unchanged.

Adds spec coverage for both attribute values, boolean property
reflection, null removal, and post-removal property writes.

Fixes microsoft#36462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: web-components TextInput spellcheck attr converter throws on null/undefined (null.toString)

1 participant