LearnNewsExamplesServices
Frontmatter
id5255
titleform.field.Select: afterSetRecord() => removing old values from selections
stateClosed
labels
bug
assigneestobiu
createdAtFeb 20, 2024, 12:14 PM
updatedAtFeb 20, 2024, 12:27 PM
githubUrlhttps://github.com/neomjs/neo/issues/5255
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 20, 2024, 12:27 PM

form.field.Select: afterSetRecord() => removing old values from selections

Closed v8.1.0 bug
tobiu
tobiu commented on Feb 20, 2024, 12:14 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

tobiu added the bug label on Feb 20, 2024, 12:14 PM
tobiu assigned to @tobiu on Feb 20, 2024, 12:15 PM
tobiu referenced in commit 1666ce2 - "form.field.Select: afterSetValue() => removing old values from selections #5255" on Feb 20, 2024, 12:18 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
tobiu referenced in commit 934fa83 - "form.field.Select: afterSetValue() => removing old values from selections #5255" on Mar 26, 2024, 5:29 PM