Skip to content

Commit 8271e9d

Browse files
licanhuaRebeccaAnne
andauthored
map title to value for input (#6526)
Co-authored-by: RebeccaAnne <rebecch@microsoft.com>
1 parent bb14fe7 commit 8271e9d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/nodejs/adaptivecards/src/card-elements.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,8 +3373,9 @@ export class ChoiceSetInput extends Input {
33733373

33743374
for (let choice of this.choices) {
33753375
let option = document.createElement("option");
3376-
option.value = <string>choice.value;
3377-
option.text = <string>choice.title;
3376+
// To fix https://stackoverflow.com/questions/29882361/show-datalist-labels-but-submit-the-actual-value
3377+
// value is mapped to choice.title other than choice.value
3378+
option.value = <string>choice.title;
33783379
option.setAttribute("aria-label", <string>choice.title);
33793380

33803381
dataList.appendChild(option);
@@ -3491,6 +3492,13 @@ export class ChoiceSetInput extends Input {
34913492
return this._selectElement.selectedIndex > 0 ? this._selectElement.value : undefined;
34923493
}
34933494
else if (this._textInput) {
3495+
for (let choice of this.choices)
3496+
{
3497+
if (choice.title && this._textInput.value === choice.title)
3498+
{
3499+
return choice.value;
3500+
}
3501+
}
34943502
return this._textInput.value;
34953503
}
34963504
else if (this._toggleInputs && this._toggleInputs.length > 0) {

0 commit comments

Comments
 (0)