Skip to content

Commit

Permalink
FIx: On adding new item in radio group if there is a large number in …
Browse files Browse the repository at this point in the history
…choices it hangs the browser #958
  • Loading branch information
andrewtelnov committed Sep 15, 2020
1 parent e4bee0f commit f3054d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -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 "";
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
14 changes: 11 additions & 3 deletions tests/utilsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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() },
Expand All @@ -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: {} } }
Expand Down

0 comments on commit f3054d9

Please sign in to comment.