Skip to content
This repository has been archived by the owner on Feb 25, 2021. It is now read-only.

Commit

Permalink
Text Area Bind Fix for issue #434 (#439)
Browse files Browse the repository at this point in the history
* Text Area Bind Fix for issue #434

* Correct Typo/Mispelling on test method name.
  • Loading branch information
RyoukoKonpaku authored and SteveSandersonMS committed Mar 30, 2018
1 parent cdeb36d commit c9c80bf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 29 additions & 0 deletions test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/BindTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,35 @@ public void CanBindTextbox_InitiallyPopulated()
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()
Expand Down
15 changes: 15 additions & 0 deletions test/testapps/BasicTestApp/BindCasesComponent.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<span id="textbox-initially-populated-value">@textboxInitiallyPopulatedValue</span>
</p>

<h2>Text Area</h2>
<p>
Initially blank:
<textarea id="textarea-initially-blank" @bind(textAreaIntiallyBlankValue)></textarea>
<span id="textarea-initially-blank-value">@textAreaIntiallyBlankValue</span>
</p>
<p>
Initially populated:
<textarea id="textarea-initially-populated" @bind(textAreaIntiallyPopulatedValue)></textarea>
<span id="textarea-initially-populated-value">@textAreaIntiallyPopulatedValue</span>
</p>

<h2>Checkbox</h2>
<p>
Initially unchecked:
Expand Down Expand Up @@ -41,6 +53,9 @@
string textboxInitiallyBlankValue = null;
string textboxInitiallyPopulatedValue = "Hello";

string textAreaIntiallyBlankValue = null;
string textAreaIntiallyPopulatedValue = "Hello";

bool checkboxInitiallyUncheckedValue = false;
bool checkboxInitiallyCheckedValue = true;

Expand Down

0 comments on commit c9c80bf

Please sign in to comment.