From f3054d9b862a1b7066b067aed861782b758e0772 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Tue, 15 Sep 2020 10:00:55 +0300 Subject: [PATCH] FIx: On adding new item in radio group if there is a large number in choices it hangs the browser #958 --- src/utils/utils.ts | 7 ++++--- tests/utilsTests.ts | 14 +++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 34d1430dab..1aa18292d0 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,5 +1,5 @@ import * as ko from "knockout"; -import { Serializer } from 'survey-knockout'; +import { Serializer } from "survey-knockout"; function getNumericFromString(str: string): string { if (!str) return ""; @@ -8,6 +8,7 @@ function getNumericFromString(str: string): string { if (str[i] >= "0" && str[i] <= "9") { num = str[i] + num; } + if (num.length == 10) break; } return num; } @@ -160,9 +161,9 @@ ko.bindingHandlers["afterRenderParent"] = { export function isPropertyVisible(obj: any, propertyName: string) { let result = true; - if(!!obj && typeof obj.getType === "function") { + if (!!obj && typeof obj.getType === "function") { const property = Serializer.findProperty(obj.getType(), propertyName); result = !property || property.visible; } return result; -} \ No newline at end of file +} diff --git a/tests/utilsTests.ts b/tests/utilsTests.ts index 3b25429210..9ef8dab518 100644 --- a/tests/utilsTests.ts +++ b/tests/utilsTests.ts @@ -4,7 +4,7 @@ import ko from "knockout"; export default QUnit.module("UtilsTests"); -QUnit.test("getNextValue", function(assert) { +QUnit.test("getNextValue", function (assert) { var prefix = "item"; assert.equal(getNextValue(prefix, ["item4", "item5", "item3"]), "item6"); assert.equal( @@ -26,9 +26,17 @@ QUnit.test("getNextValue", function(assert) { assert.equal(getNextValue(prefix, ["yes"]), "no"); assert.equal(getNextValue(prefix, ["No"]), "Yes"); assert.equal(getNextValue(prefix, ["TRUE"]), "FALSE"); + assert.equal( + getNextValue(prefix, [ + "12345671234567890", + "12345671234567891", + "12345671234567892", + ]), + "12345671234567893" + ); }); -QUnit.test("DesignerContainerViewModel changed unsubscribe", function(assert) { +QUnit.test("DesignerContainerViewModel changed unsubscribe", function (assert) { var changed = ko.observable(0); var dcm = new DesignerContainerViewModel( { changed: changed, tabs: ko.observableArray() }, @@ -40,7 +48,7 @@ QUnit.test("DesignerContainerViewModel changed unsubscribe", function(assert) { assert.ok(dcm.isOpen(), "still open"); }); -QUnit.test("DesignerContainerViewModel default icons", function(assert) { +QUnit.test("DesignerContainerViewModel default icons", function (assert) { var dcm = new DesignerContainerViewModel( { tabs: ko.observableArray() }, { element: { offsetWidth: 0, style: {} } }