Fixes #8092 SelectWidget does not work with multiple options organise… (#8093)

* Fixes #8092 SelectWidget does not work with multiple options organised into group

* Consolidate variables

* Apply suggestion from @saqimtiaz

* Update core/modules/widgets/select.js

Co-authored-by: Mario Pietsch <pmariojo@gmail.com>

* added release note

* chore: lint fixes

---------

Co-authored-by: Saq Imtiaz <saq.imtiaz@gmail.com>
Co-authored-by: Mario Pietsch <pmariojo@gmail.com>
This commit is contained in:
buggyj
2026-01-25 17:02:18 +01:00
committed by GitHub
parent eb3a80968e
commit 75647eb623
2 changed files with 21 additions and 2 deletions

View File

@@ -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();

View File

@@ -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.