Skip to content

Commit f3054d9

Browse files
committed
FIx: On adding new item in radio group if there is a large number in choices it hangs the browser #958
1 parent e4bee0f commit f3054d9

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/utils/utils.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as ko from "knockout";
2-
import { Serializer } from 'survey-knockout';
2+
import { Serializer } from "survey-knockout";
33

44
function getNumericFromString(str: string): string {
55
if (!str) return "";
@@ -8,6 +8,7 @@ function getNumericFromString(str: string): string {
88
if (str[i] >= "0" && str[i] <= "9") {
99
num = str[i] + num;
1010
}
11+
if (num.length == 10) break;
1112
}
1213
return num;
1314
}
@@ -160,9 +161,9 @@ ko.bindingHandlers["afterRenderParent"] = {
160161

161162
export function isPropertyVisible(obj: any, propertyName: string) {
162163
let result = true;
163-
if(!!obj && typeof obj.getType === "function") {
164+
if (!!obj && typeof obj.getType === "function") {
164165
const property = Serializer.findProperty(obj.getType(), propertyName);
165166
result = !property || property.visible;
166167
}
167168
return result;
168-
}
169+
}

tests/utilsTests.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ko from "knockout";
44

55
export default QUnit.module("UtilsTests");
66

7-
QUnit.test("getNextValue", function(assert) {
7+
QUnit.test("getNextValue", function (assert) {
88
var prefix = "item";
99
assert.equal(getNextValue(prefix, ["item4", "item5", "item3"]), "item6");
1010
assert.equal(
@@ -26,9 +26,17 @@ QUnit.test("getNextValue", function(assert) {
2626
assert.equal(getNextValue(prefix, ["yes"]), "no");
2727
assert.equal(getNextValue(prefix, ["No"]), "Yes");
2828
assert.equal(getNextValue(prefix, ["TRUE"]), "FALSE");
29+
assert.equal(
30+
getNextValue(prefix, [
31+
"12345671234567890",
32+
"12345671234567891",
33+
"12345671234567892",
34+
]),
35+
"12345671234567893"
36+
);
2937
});
3038

31-
QUnit.test("DesignerContainerViewModel changed unsubscribe", function(assert) {
39+
QUnit.test("DesignerContainerViewModel changed unsubscribe", function (assert) {
3240
var changed = ko.observable(0);
3341
var dcm = new DesignerContainerViewModel(
3442
{ changed: changed, tabs: ko.observableArray() },
@@ -40,7 +48,7 @@ QUnit.test("DesignerContainerViewModel changed unsubscribe", function(assert) {
4048
assert.ok(dcm.isOpen(), "still open");
4149
});
4250

43-
QUnit.test("DesignerContainerViewModel default icons", function(assert) {
51+
QUnit.test("DesignerContainerViewModel default icons", function (assert) {
4452
var dcm = new DesignerContainerViewModel(
4553
{ tabs: ko.observableArray() },
4654
{ element: { offsetWidth: 0, style: {} } }

0 commit comments

Comments
 (0)