parent
fde783911b
commit
4310fa72f7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -372,7 +372,7 @@ export class BrowserRenderer {
|
||||||
}
|
}
|
||||||
case 'OPTION': {
|
case 'OPTION': {
|
||||||
const value = attributeFrame ? frameReader.attributeValue(attributeFrame) : null;
|
const value = attributeFrame ? frameReader.attributeValue(attributeFrame) : null;
|
||||||
if (value) {
|
if (value || value === '') {
|
||||||
element.setAttribute('value', value);
|
element.setAttribute('value', value);
|
||||||
} else {
|
} else {
|
||||||
element.removeAttribute('value');
|
element.removeAttribute('value');
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,11 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
Browser.FindElement(By.Id("select-box-add-option")).Click();
|
Browser.FindElement(By.Id("select-box-add-option")).Click();
|
||||||
Browser.Equal("Fourth", () => boundValue.Text);
|
Browser.Equal("Fourth", () => boundValue.Text);
|
||||||
Assert.Equal("Fourth choice", target.SelectedOption.Text);
|
Assert.Equal("Fourth choice", target.SelectedOption.Text);
|
||||||
|
|
||||||
|
// Verify we can select options whose value is empty
|
||||||
|
// https://github.com/aspnet/AspNetCore/issues/17735
|
||||||
|
target.SelectByText("Empty value");
|
||||||
|
Browser.Equal(string.Empty, () => boundValue.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -227,6 +232,11 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||||
// Modify target; verify value is updated
|
// Modify target; verify value is updated
|
||||||
target.SelectByText("Third choice");
|
target.SelectByText("Third choice");
|
||||||
Browser.Equal("Third", () => boundValue.Text);
|
Browser.Equal("Third", () => boundValue.Text);
|
||||||
|
|
||||||
|
// Verify we can select options whose value is empty
|
||||||
|
// https://github.com/aspnet/AspNetCore/issues/17735
|
||||||
|
target.SelectByText("Empty value");
|
||||||
|
Browser.Equal(string.Empty, () => boundValue.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,7 @@
|
||||||
<select id="select-box" @bind="selectValue">
|
<select id="select-box" @bind="selectValue">
|
||||||
<optgroup label="Some choices">
|
<optgroup label="Some choices">
|
||||||
<!-- Show it also works with optgroup -->
|
<!-- Show it also works with optgroup -->
|
||||||
|
<option value="">Empty value</option>
|
||||||
<option value=@SelectableValue.First>First choice</option>
|
<option value=@SelectableValue.First>First choice</option>
|
||||||
<option value=@SelectableValue.Second>Second choice</option>
|
<option value=@SelectableValue.Second>Second choice</option>
|
||||||
<option value=@SelectableValue.Third>Third choice</option>
|
<option value=@SelectableValue.Third>Third choice</option>
|
||||||
|
|
@ -246,6 +247,7 @@
|
||||||
<p>
|
<p>
|
||||||
<select id="select-markup-box" @bind="selectMarkupValue">
|
<select id="select-markup-box" @bind="selectMarkupValue">
|
||||||
<optgroup label="Some choices">
|
<optgroup label="Some choices">
|
||||||
|
<option value="">Empty value</option>
|
||||||
<option value="First">First choice</option>
|
<option value="First">First choice</option>
|
||||||
<option value="Second">Second choice</option>
|
<option value="Second">Second choice</option>
|
||||||
<option value="Third">Third choice</option>
|
<option value="Third">Third choice</option>
|
||||||
|
|
@ -368,8 +370,8 @@
|
||||||
|
|
||||||
bool includeFourthOption = false;
|
bool includeFourthOption = false;
|
||||||
enum SelectableValue { First, Second, Third, Fourth }
|
enum SelectableValue { First, Second, Third, Fourth }
|
||||||
SelectableValue selectValue = SelectableValue.Second;
|
SelectableValue? selectValue = SelectableValue.Second;
|
||||||
SelectableValue selectMarkupValue = SelectableValue.Second;
|
SelectableValue? selectMarkupValue = SelectableValue.Second;
|
||||||
|
|
||||||
void AddAndSelectNewSelectOption()
|
void AddAndSelectNewSelectOption()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue