Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit ec22f91

Browse files
author
Francois-Xavier Gentilhomme
committed
[FIX] fixes ugly hack for selected candidate
1 parent af9f2d5 commit ec22f91

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

myscript-text-web.html

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<template>
7373
<div class="resultField" hidden="[[ displayResultZone(hideresult, unloaded) ]]">
7474
<template is="dom-repeat" id="candidateList" items="[[ candidates ]]" as="candidate">
75-
<span id="candidate" class="candidate" index="[[ index ]]" selected$="[[ candidate.selected ]]"
75+
<span id="candidate" class="candidate" selected$="[[ _isSelected(index, result.textSegmentResult.selectedCandidateIdx) ]]"
7676
inner-h-t-m-l="[[ candidate.customlabel ]]" on-tap="_select"></span>
7777
</template>
7878
</div>
@@ -164,7 +164,6 @@
164164
myscriptTextWebElement.result = eventDetail.rawResult.result;
165165
myscriptTextWebElement.resultlabel = eventDetail.rawResult.result.textSegmentResult.candidates[eventDetail.rawResult.result.textSegmentResult.selectedCandidateIdx].label;
166166
myscriptTextWebElement.candidates = eventDetail.rawResult.result.textSegmentResult.candidates;
167-
myscriptTextWebElement.candidates[eventDetail.rawResult.result.textSegmentResult.selectedCandidateIdx].selected = true; // FIXME: ugly hack to mark selected candidate
168167
textUpdateCandidatesCustomLabel(myscriptTextWebElement);
169168
}
170169
}
@@ -761,18 +760,8 @@
761760
this.result = {};
762761
this.result = result;
763762
},
764-
/**
765-
* Determine if the candidate is selected
766-
* @param candidate
767-
* @param result
768-
* @returns {boolean}
769-
* @private
770-
*/
771-
_isSelected: function (candidate, result) {
772-
if (result && result.textSegmentResult) {
773-
return (candidate === result.textSegmentResult.candidates[result.textSegmentResult.selectedCandidateIdx]);
774-
}
775-
return false;
763+
_isSelected: function (index, selectedIndex) {
764+
return index === selectedIndex;
776765
},
777766
_getChildSegments: function (candidate, result, type) {
778767
var segments = [];

0 commit comments

Comments
 (0)