Frontmatter
| id | 5255 |
| title | form.field.Select: afterSetRecord() => removing old values from selections |
| state | Closed |
| labels | bug |
| assignees | tobiu |
| createdAt | Feb 20, 2024, 12:14 PM |
| updatedAt | Feb 20, 2024, 12:27 PM |
| githubUrl | https://github.com/neomjs/neo/issues/5255 |
| author | tobiu |
| commentsCount | 0 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Feb 20, 2024, 12:27 PM |
form.field.Select: afterSetRecord() => removing old values from selections
tobiu assigned to @tobiu on Feb 20, 2024, 12:15 PM
tobiu changed title from form.field.Select: afterSetValue() => removing old values from selections to form.field.Select: afterSetRecord() => removing old values from selections on Feb 20, 2024, 12:27 PM
tobiu closed this issue on Feb 20, 2024, 12:27 PM
old code:
afterSetRecord(value, oldValue) { let me = this, list = me.list, selectionModel = list?.selectionModel, valueField = me.valueField, nodeId; if (oldValue) { nodeId = list?.getItemId(oldValue[valueField]); selectionModel?.deselect(nodeId); } if (value) { nodeId = list?.getItemId(value[valueField]); selectionModel?.select(nodeId); } }new code:
afterSetRecord(value, oldValue) { if (this._picker?.isVisible) { let me = this, selectionModel = me.list?.selectionModel; if (value) { selectionModel?.select(value); } else { selectionModel.deselectAll(); } } }we need a merge of both. if we are switching from one record to another, the old selection should get removed (i would not assume that the selModel has singleSelection activated).
if there is no value, we need the deselectAll() call.
@ExtAnimal