1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 03:27:18 +00:00

Fix checkbox widget when listIndex field undefined (#7679)

This commit is contained in:
Robin Munn 2023-08-15 23:12:49 +07:00 committed by GitHub
parent 6c67dc8235
commit 779ac28bd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,7 +116,7 @@ CheckboxWidget.prototype.getValue = function() {
} else { } else {
list = $tw.utils.parseStringArray(this.checkboxDefault || "") || []; list = $tw.utils.parseStringArray(this.checkboxDefault || "") || [];
} }
} else if (this.checkboxListIndex) { } else if(this.checkboxListIndex) {
list = $tw.utils.parseStringArray(this.wiki.extractTiddlerDataItem(tiddler,this.checkboxListIndex,this.checkboxDefault || "")) || []; list = $tw.utils.parseStringArray(this.wiki.extractTiddlerDataItem(tiddler,this.checkboxListIndex,this.checkboxDefault || "")) || [];
} else { } else {
list = this.wiki.filterTiddlers(this.checkboxFilter,this) || []; list = this.wiki.filterTiddlers(this.checkboxFilter,this) || [];
@ -215,6 +215,8 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
if($tw.utils.isArray(fieldContents)) { if($tw.utils.isArray(fieldContents)) {
// Make a copy so we can modify it without changing original that's refrenced elsewhere // Make a copy so we can modify it without changing original that's refrenced elsewhere
listContents = fieldContents.slice(0); listContents = fieldContents.slice(0);
} else if(fieldContents === undefined) {
listContents = [];
} else if(typeof fieldContents === "string") { } else if(typeof fieldContents === "string") {
listContents = $tw.utils.parseStringArray(fieldContents); listContents = $tw.utils.parseStringArray(fieldContents);
// No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere // No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere