Skip to content

DOM sync removes checkbox custom values in some cases #50995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SteveSandersonMS opened this issue Sep 28, 2023 · 0 comments
Closed

DOM sync removes checkbox custom values in some cases #50995

SteveSandersonMS opened this issue Sep 28, 2023 · 0 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Sep 28, 2023

Repro: <input type="checkbox" value="myvalue" checked>

If you do an enhanced nav and the resulting content also contains that exact same markup, the value attribute will get overwritten with the string true. Then when you submit the form you'll get wrong results.

I tracked this down to a trivial logic error in the DOM sync code - fix submitted in #50991

@SteveSandersonMS SteveSandersonMS added the area-blazor Includes: Blazor, Razor Components label Sep 28, 2023
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Sep 28, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0 milestone Sep 28, 2023
mkArtakMSFT pushed a commit that referenced this issue Sep 28, 2023
# Fix checkbox DOM sync

Unbreaks checkboxes with custom value attributes.

## Description

There was a trivial logic error in the DOM syncing code, causing the `value` attribute on checkboxes to get wrongly overwritten in a certain case (if there was a custom value attribute and `checked` was unchanged).

Fixes #50995

## Customer Impact

In some cases, checkbox values would get corrupted after an enhanced navigation. This would break form functionality.

The specific scenario was "checkboxes with a custom value attribute, when an enhanced nav leaves the `checked` state unchanged".

## Regression?

- [ ] Yes
- [x] No

[If yes, specify the version the behavior has regressed from]

## Risk

- [ ] High
- [ ] Medium
- [x] Low

Very low because it's a tiny code edit, and only affects a very specific scenario, and the old logic was (in retrospect) definitely incorrect.

## Verification

- [x] Manual (required)
- [x] Automated

## Packaging changes reviewed?

- [ ] Yes
- [ ] No
- [x] N/A
@wtgodbe wtgodbe modified the milestones: 8.0, 8.0.0 Oct 3, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

3 participants