Skip to content

Commit 2d6f498

Browse files
committed
Merge branch 'master' of https://github.com/surveyjs/widgets
2 parents 02ceb90 + bcb665d commit 2d6f498

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [1.8.12](https://github.com/surveyjs/custom-widgets/compare/v1.8.11...v1.8.12) (2020-10-28)
6+
7+
### [1.8.11](https://github.com/surveyjs/custom-widgets/compare/v1.8.10...v1.8.11) (2020-10-23)
8+
59
### [1.8.10](https://github.com/surveyjs/custom-widgets/compare/v1.8.9...v1.8.10) (2020-10-21)
610

711
### [1.8.9](https://github.com/surveyjs/custom-widgets/compare/v1.8.8...v1.8.9) (2020-10-14)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "surveyjs-widgets",
3-
"version": "1.8.10",
3+
"version": "1.8.12",
44
"scripts": {
55
"start": "npm run build && live-server",
66
"watch": "webpack --env.buildType dev --watch",

src/select2-tagbox.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,23 @@ function init(Survey, $) {
107107
.trigger("change");
108108
} else {
109109
$el.val(question.value).trigger("change");
110+
111+
if (
112+
question.allowAddNewTag &&
113+
$el.val().length !== question.value.length
114+
) {
115+
question.value.forEach(function (choiceValue) {
116+
if ($el.val().indexOf(choiceValue) === -1) {
117+
var newOption = new Option(
118+
choiceValue,
119+
choiceValue,
120+
true,
121+
true
122+
);
123+
$el.append(newOption).trigger("change");
124+
}
125+
});
126+
}
110127
}
111128
self.fixStyles(el);
112129
updateComment();

src/select2.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function init(Survey, $) {
6363
if (isSettingValue) return;
6464
question.comment = $otherElement.val();
6565
});
66+
6667
var updateComment = function () {
6768
$otherElement.val(question.comment);
6869
if (question.isOtherSelected) {
@@ -105,12 +106,18 @@ function init(Survey, $) {
105106
$el.select2(settings);
106107
question.keepIncorrectValues = true;
107108
} else {
108-
settings.data = question.visibleChoices.map(function (choice) {
109-
return {
110-
id: choice.value,
111-
text: choice.text,
112-
};
113-
});
109+
var data = [];
110+
if (!!settings.placeholder || question.showOptionsCaption) {
111+
data.push({ id: "", text: "" });
112+
}
113+
settings.data = data.concat(
114+
question.visibleChoices.map(function (choice) {
115+
return {
116+
id: choice.value,
117+
text: choice.text,
118+
};
119+
})
120+
);
114121
$el.select2(settings);
115122
}
116123
// fixed width accrording to https://stackoverflow.com/questions/45276778/select2-not-responsive-width-larger-than-container

0 commit comments

Comments
 (0)