diff --git a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/BrowserRenderer.ts b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/BrowserRenderer.ts index d0da6c1965..495f9f2a9b 100644 --- a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/BrowserRenderer.ts +++ b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/BrowserRenderer.ts @@ -228,6 +228,7 @@ export class BrowserRenderer { switch (element.tagName) { case 'INPUT': case 'SELECT': + case 'TEXTAREA': if (isCheckbox(element)) { (element as HTMLInputElement).checked = value === 'True'; } else { diff --git a/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/BindTest.cs b/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/BindTest.cs index 8c20996df0..1304d54b29 100644 --- a/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/BindTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/BindTest.cs @@ -47,6 +47,35 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests target.SendKeys("Changed value\t"); Assert.Equal("Changed value", boundValue.Text); } + + [Fact] + public void CanBindTextArea_InitiallyBlank() + { + var target = Browser.FindElement(By.Id("textarea-initially-blank")); + var boundValue = Browser.FindElement(By.Id("textarea-initially-blank-value")); + Assert.Equal(string.Empty, target.GetAttribute("value")); + Assert.Equal(string.Empty, boundValue.Text); + + // Modify target; verify value is updated + target.SendKeys("Changed value"); + Assert.Equal(string.Empty, boundValue.Text); // Don't update as there's no change event fired yet. + target.SendKeys("\t"); + Assert.Equal("Changed value", boundValue.Text); + } + + [Fact] + public void CanBindTextArea_InitiallyPopulated() + { + var target = Browser.FindElement(By.Id("textarea-initially-populated")); + var boundValue = Browser.FindElement(By.Id("textarea-initially-populated-value")); + Assert.Equal("Hello", target.GetAttribute("value")); + Assert.Equal("Hello", boundValue.Text); + + // Modify target; verify value is updated + target.Clear(); + target.SendKeys("Changed value\t"); + Assert.Equal("Changed value", boundValue.Text); + } [Fact] public void CanBindCheckbox_InitiallyUnchecked() diff --git a/test/testapps/BasicTestApp/BindCasesComponent.cshtml b/test/testapps/BasicTestApp/BindCasesComponent.cshtml index fbb6d3b739..86a418ae42 100644 --- a/test/testapps/BasicTestApp/BindCasesComponent.cshtml +++ b/test/testapps/BasicTestApp/BindCasesComponent.cshtml @@ -10,6 +10,18 @@ @textboxInitiallyPopulatedValue

+

Text Area

+

+ Initially blank: + + @textAreaIntiallyBlankValue +

+

+ Initially populated: + + @textAreaIntiallyPopulatedValue +

+

Checkbox

Initially unchecked: @@ -41,6 +53,9 @@ string textboxInitiallyBlankValue = null; string textboxInitiallyPopulatedValue = "Hello"; + string textAreaIntiallyBlankValue = null; + string textAreaIntiallyPopulatedValue = "Hello"; + bool checkboxInitiallyUncheckedValue = false; bool checkboxInitiallyCheckedValue = true;