Skip to content

Fix rendering of HTML enumerated boolean attributes (draggable, spellcheck, contenteditable) - #67970

Closed
BrundhaVelusamy wants to merge 34 commits into
dotnet:mainfrom
BrundhaVelusamy:DraggableAttribute
Closed

BrundhaVelusamy wants to merge 34 commits into
dotnet:mainfrom
BrundhaVelusamy:DraggableAttribute

Conversation

@BrundhaVelusamy

@BrundhaVelusamy BrundhaVelusamy commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

This change updates Blazor's attribute rendering behavior for HTML enumerated boolean attributes so that they are rendered with explicit string values ("true" / "false") instead of using the standard boolean attribute presence/absence pattern.

Blazor currently treats all bool attributes as HTML boolean attributes:

  • true → attribute present
  • false → attribute omitted

This behavior is correct for attributes such as disabled, checked, and readonly, but it does not match the semantics of HTML enumerated attributes like:

  • draggable
  • spellcheck
  • contenteditable

These attributes expect explicit "true" or "false" values and may not behave consistently when rendered as presence/absence attributes.

Changes

Special handling has been added for the following enumerated attributes:

  • draggable
  • spellcheck
  • contenteditable

Examples:

Before:

<div draggable></div>
<div spellcheck></div>
<div contenteditable></div>

After:

<div draggable="true"></div>
<div spellcheck="true"></div>
<div contenteditable="true"></div>

And:

<div draggable="false"></div>
<div spellcheck="false"></div>
<div contenteditable="false"></div>

Output

Before:

DraggableAttr_Issue.mp4

After:

DraggableAttr_Fix.mp4

Fixes #60137

While the issue was originally reported for draggable, the implementation applies the same behavior to other HTML enumerated attributes that share the same "true"/"false" value semantics to ensure consistent rendering behavior.

@BrundhaVelusamy
BrundhaVelusamy requested a review from a team as a code owner July 23, 2026 07:31
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @BrundhaVelusamy. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copilot AI review requested due to automatic review settings August 4, 2026 12:05

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.

Pull request overview

This PR updates Blazor’s element-attribute rendering so that certain HTML enumerated attributes supplied as bool are emitted with explicit "true"/"false" string values (instead of presence/absence), ensuring spec-compliant HTML and more consistent browser behavior for drag-and-drop and related features.

Changes:

  • Update RenderTreeBuilder to render enumerated bool attributes with explicit "true"/"false" string values for elements (while preserving boxed bool behavior for component parameters).
  • Add RenderTreeBuilder unit tests covering enumerated attributes (including case-insensitive matching) and confirming regular boolean attributes remain unchanged.
  • Add an HtmlRenderer test validating the serialized HTML output for draggable when supplied as bool.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Components/Components/src/Rendering/RenderTreeBuilder.cs Adds enumerated-attribute handling so element attributes like draggable render ="true"/"false" rather than presence/absence.
src/Components/Components/test/Rendering/RenderTreeBuilderTest.cs Adds tests verifying frames for enumerated attributes use explicit string values and that component parameters remain boxed bools.
src/Components/Web/test/HtmlRendering/HtmlRendererTest.cs Adds rendering test asserting HTML output includes draggable="true" / draggable="false".
Suppressed comments (1)

src/Components/Components/src/Rendering/RenderTreeBuilder.cs:386

  • The XML doc comment says a boxed false boolean value for an element attribute will be omitted, but enumerated bool attributes now render an explicit "false" value. Please update the doc comment to reflect the enumerated-attribute exception.
            else if (value is bool boolValue)
            {
                if (IsEnumeratedBoolAttribute(name))
                {
                    _entries.AppendAttribute(sequence, name, boolValue ? "true" : "false");
                }
                else if (boolValue)

@BrundhaVelusamy BrundhaVelusamy changed the title Fix draggable Attribute Rendering for Blazor Elements Fix rendering of HTML enumerated boolean attributes (draggable, spellcheck, contenteditable) Aug 4, 2026
@PureWeen

Copy link
Copy Markdown
Member

/review

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

Valueless draggable attributes are still stored as boxed true, causing serializer round-trips to change their rendered value on interactive activation without any application state change.

1 open issue
2 resolved since last review

Review effort: Balanced

@github-actions github-actions Bot 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.

Source-only review of frozen head c98584e45d29ce7f68fcfb3afc48fd5207b3a682 (merge base 9ea8a84d9c7c1a63256d2256969d5a6c66103d83, base tip and trusted guidance commit 18781e9d03cba0f3df9cdf7fae90f77771ca9f00).

Two source-reachable candidates remain unresolved because the frozen evidence does not include the binding contracts needed to determine whether the valueless overload and writingsuggestions belong within this change. Both are identified inline rather than asserted as verified defects.

Existing-feedback coverage: the missing real-browser regression boundary is already covered by inline thread 4358157919; deduplication is neutral and does not imply that concern is settled. The current unit test exercises the typed Boolean overload only, while the assigned Components guidance requires real-browser coverage for browser-owned user-visible behavior. Feedback posted after bundle preparation is not observable here.

Guide completion:

  • docs/CrossCuttingGuidance.md: complete for source-reviewable change shape, API/docs, correctness, producer/consumer paths, performance, compatibility, and changed-test fidelity.
  • docs/BlazorComponentsGuidance.md: complete for rendering, overload compatibility, static/interactive consumption, documentation, and regression-test fidelity.
  • Both workers used the required review-guide-worker profile and explicit gpt-5.6-sol model; reasoning effort was not supplied (runtime default). The post-gate candidates were independently checked by one review-candidate-verifier on the same model.

Uncovered areas: none among materially changed files; routed cross-cutting and Blazor Components guidance covered the change. Runtime, browser, CI, and sample execution were excluded by the supplied source-only policy, and security assessment was excluded by repository review policy. No target code was executed; red/green and browser behavior remain unverified. Proof is limited to tracked frozen Git bytes; symlink, submodule, LFS target behavior, external HTML contracts, and post-preparation feedback are unavailable.

Generated by ASP.NET Core Pull Request Review for #67970 · copilot · gpt56 · 219.3 AIC · ⌖ 8.77 AIC · ⊞ 20.1K
Comment /review to run again

@PureWeen

Copy link
Copy Markdown
Member

Copilot's local review panel found no issues to raise at this commit.

All three local arms completed at c98584e45d29ce7f68fcfb3afc48fd5207b3a682. The panel's remaining candidate was already covered by the current-head hosted review, so no duplicate inline comment is being added. This local-panel result does not resolve or supersede existing review threads.

Informational discarded checks: The explicit "false" attribute values, including their presence and inheritance effects, match the PR's documented intent. Component Boolean preservation, duplicate precedence, downstream string handling, and update-path reachability yielded no additional supported defect; no material performance regression was established.

Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block agent-reviewed-approved.

Untested coverage gaps: The changed object/splat path, the other two attribute names, case matching, and browser rendering/update scenarios were not exercised. The existing browser-regression discussion remains in thread 4358157919; it is not being reposted as a new finding.

Validation boundary: all three arms used frozen-source analysis; no target build, tests, or browser validation was run.

Human-directed and GitHub Copilot-generated.

@PureWeen

Copy link
Copy Markdown
Member

/review

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

Required real-browser coverage is missing for the four enumerated attributes, including initial rendering and true → false → true updates on Server and WebAssembly.

1 open issue
1 resolved since last review

Review effort: Balanced

@PureWeen

Copy link
Copy Markdown
Member

The local review panel completed at 65aaa41c5a364e6a4b37c5e10bd848226226acf7 with no new blocking findings to add. The current-head browser-coverage thread is still unresolved, so this result does not clear that feedback or qualify the PR for agent-reviewed-approved. No duplicate inline comment is being added.

Informational discarded/unresolved diagnostics: One arm questioned whether the updated AddAttribute XML docs should also describe explicit "true" values and name writingsuggestions. Its verifier dropped the candidate because the existing "false" clause is accurate, "such as" gives examples, and no binding documentation requirement established a defect. Both independent double-checks declined inline publication. Another arm left the valueless overload's HTML/DOM contract unverified; the author's existing reply explains the intentional empty-string representation. These are diagnostics, not newly established failures.

The explicit true/false presence and inheritance changes match the documented PR intent. Routine discarded checks established no additional defect in component Boolean preservation, splatting, duplicate precedence, repeated updates, downstream string handling, or newly produced fragment replay. No material lookup-cost/shared-set issue, supported raw-event-update failure, ARIA scope obligation, or cross-version fragment contract was established.

Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block agent-reviewed-approved.

Untested coverage gaps: The arms did not execute target rendering or browser scenarios. Static output, interactive initial rendering and updates, splatting, the remaining attribute-name/casing cases, and browser properties remain without new runtime evidence from this panel. The existing browser-coverage thread above is not being reposted as a new finding.

Validation boundary: G and S used frozen-source analysis; O additionally ran a scratch Razor code-generation probe, not PR code. No target build, tests, or browser validation ran.

Human-directed and GitHub Copilot-generated.

@BrundhaVelusamy

Copy link
Copy Markdown
Contributor Author

The local review panel completed at 65aaa41c5a364e6a4b37c5e10bd848226226acf7 with no new blocking findings to add. The current-head browser-coverage thread is still unresolved, so this result does not clear that feedback or qualify the PR for agent-reviewed-approved. No duplicate inline comment is being added.

Informational discarded/unresolved diagnostics: One arm questioned whether the updated AddAttribute XML docs should also describe explicit "true" values and name writingsuggestions. Its verifier dropped the candidate because the existing "false" clause is accurate, "such as" gives examples, and no binding documentation requirement established a defect. Both independent double-checks declined inline publication. Another arm left the valueless overload's HTML/DOM contract unverified; the author's existing reply explains the intentional empty-string representation. These are diagnostics, not newly established failures.

The explicit true/false presence and inheritance changes match the documented PR intent. Routine discarded checks established no additional defect in component Boolean preservation, splatting, duplicate precedence, repeated updates, downstream string handling, or newly produced fragment replay. No material lookup-cost/shared-set issue, supported raw-event-update failure, ARIA scope obligation, or cross-version fragment contract was established.

Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block agent-reviewed-approved.

Untested coverage gaps: The arms did not execute target rendering or browser scenarios. Static output, interactive initial rendering and updates, splatting, the remaining attribute-name/casing cases, and browser properties remain without new runtime evidence from this panel. The existing browser-coverage thread above is not being reposted as a new finding.

Validation boundary: G and S used frozen-source analysis; O additionally ran a scratch Razor code-generation probe, not PR code. No target build, tests, or browser validation ran.

Human-directed and GitHub Copilot-generated.

@PureWeen, Thanks for the follow-up. I’ve addressed the open browser-coverage thread with one shared Selenium test that runs on both Blazor Server and WebAssembly.

The test checks the DOM attributes and corresponding browser properties for draggable, spellcheck, contenteditable, and splatted writingsuggestions on initial render and through true → false → true. It also checks that the ordinary boolean hidden attribute still uses presence and absence and that its DOM property reflects that state.

Both renderer cases failed at the initial draggable assertion with the fix disabled. Both passed with the fix restored, including the added hidden property check. I left the XML docs and valueless-attribute behavior unchanged in this follow-up.

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.

🟢 Approval recommended

No active review issues remain for the enumerated boolean attribute handling changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@PureWeen

Copy link
Copy Markdown
Member

/review

@PureWeen

Copy link
Copy Markdown
Member

Copilot's local review panel found no issues to raise at this commit.

All three local arms completed at 2a48ace4895109e745279f443adeb329070c80f8. Neither minority diagnostic cleared the required independent publication checks, so no inline review is being added.

Informational diagnostic: One arm revisited the valueless AddAttribute frame representation versus its XML summary. Both independent double-checks declined publication: browser builds already used the empty-string representation, and the intentional serializer fix has a new round-trip regression test. This did not establish a new supported compatibility failure. The existing author reply explains the empty-string choice. The explicit "false" presence/inheritance question and other routine discarded checks were already addressed in the previous panel summaries; they are not being raised again.

Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block agent-reviewed-approved.

Untested coverage gaps: This panel did not independently execute the target build, tests, or browser cases, including browser-version support for writingSuggestions and additional render-mode/casing combinations.

Validation boundary: all three arms and both independent double-checks used frozen-source evidence; no target runtime or browser validation was run.

The current-head hosted /review attempt failed its publication gate; it was not rerun.

Human-directed and GitHub Copilot-generated.

@kotlarmilos

Copy link
Copy Markdown
Member

Thank you for the contribution. Blazor maps a bool attribute value to the presence or absence of the attribute, which is correct for HTML boolean attributes. Enumerated attributes such as draggable take string values, so pass a string, for example draggable="@(isDraggable ? "true" : "false")". Special-casing a fixed list of names in RenderTreeBuilder adds a lookup to boolean attributes and changes existing output for contenteditable and spellcheck when the value is false. See #60137.

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

Labels

agent-reviewed-approved area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass boolean value to draggable attribute

7 participants