Skip to content
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

Support removing 'value' attribute #16139

Closed
jirisykora83 opened this issue Apr 23, 2018 · 1 comment
Closed

Support removing 'value' attribute #16139

jirisykora83 opened this issue Apr 23, 2018 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@jirisykora83
Copy link

Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300-preview2-008533\

Repro

@page "/"

<input value="@Text" onchange="@onTextChange" />
<div>Currently text: @Text</div>
<div onclick="@onButtonClick">SET TEXT TO NULL</div>

@{ 
	Console.WriteLine($"Render with: '{Text ?? "NULL"}'");
}

@functions
{
	public string Text { get; set; }

	protected void onTextChange(UIChangeEventArgs e)
	{
		Text = (string)e.Value;
	}

	protected void onButtonClick()
	{
		Text = null;
	}
}

When i type some text to input (click outside for call "onchange"). And then i click to "SET TEXT TO NULL". In console i see Render with: 'NULL' but input keep last value.

It fail same if i use <input bind="@Text" /> (and remove onTextChange).

Excepted behavior

Reset input text. (same like for <div>@Text</div>).

Workaround

<input value="@(Text ?? string.Empty)" onchange="@onTextChange" />

@SteveSandersonMS SteveSandersonMS changed the title Input not update if text is NULL Support removing 'value' attribute Apr 23, 2018
@SteveSandersonMS
Copy link
Member

Thanks for reporting this, @jirisykora83!

This is caused by BrowserRenderer.ts having special support for setting element values, but not having equivalent support for removing those values.

SteveSandersonMS referenced this issue in dotnet/blazor May 1, 2018
…rowserRenderer.ts. Fixes #659 and #703

* Stop the value<-->checked conversions for checkboxes. Just use native 'checked' property. Fixes #703

* Properly handle removal of 'checked' and 'value' attributes

* E2E coverage for removing 'value'
SteveSandersonMS referenced this issue in SteveSandersonMS/BlazorMigration Nov 27, 2018
…rowserRenderer.ts. Fixes #659 and #703

* Stop the value<-->checked conversions for checkboxes. Just use native 'checked' property. Fixes #703

* Properly handle removal of 'checked' and 'value' attributes

* E2E coverage for removing 'value'
@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

3 participants