diff --git a/core/modules/widgets/select.js b/core/modules/widgets/select.js index 8bc23542c..eea56cae7 100644 --- a/core/modules/widgets/select.js +++ b/core/modules/widgets/select.js @@ -121,9 +121,18 @@ SelectWidget.prototype.setSelectValue = function() { if (this.selectMultiple) { value = value === undefined ? "" : value; var select = this.getSelectDomNode(); - var values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); + var child, + values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); for(var i=0; i < select.children.length; i++){ - select.children[i].selected = values.indexOf(select.children[i].value) !== -1 + child=select.children[i]; + if(child.children.length === 0){ + child.selected = values.indexOf(child.value) !== -1; + } else { + // grouped options + for(var y=0; y < child.children.length; y++){ + child.children[y].selected = values.indexOf(child.children[y].value) !== -1; + } + } } } else { var domNode = this.getSelectDomNode(); diff --git a/editions/tw5.com/tiddlers/releasenotes/5.4.0/#8093.tid b/editions/tw5.com/tiddlers/releasenotes/5.4.0/#8093.tid new file mode 100644 index 000000000..dc967b013 --- /dev/null +++ b/editions/tw5.com/tiddlers/releasenotes/5.4.0/#8093.tid @@ -0,0 +1,10 @@ +title: $:/changenotes/5.4.0/#8093 +description: Fixes SelectWidget does not work with multiple options organised into group - issue #8092 +release: 5.4.0 +tags: $:/tags/ChangeNote +change-type: bugfix +change-category: widget +github-links: https://github.com/TiddlyWiki/TiddlyWiki5/issues/8093 +github-contributors: buggyj + +Fixed SelectWidget does not work with multiple options organised into group.