Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tobiu opened this issue Feb 20, 2024 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@tobiu
Copy link
Collaborator

tobiu commented Feb 20, 2024

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 tobiu added the bug Something isn't working label Feb 20, 2024
@tobiu tobiu self-assigned this Feb 20, 2024
@tobiu tobiu added this to To do in Client related tickets via automation Feb 20, 2024
@tobiu tobiu changed the title form.field.Select: afterSetValue() => removing old values from selections form.field.Select: afterSetRecord() => removing old values from selections Feb 20, 2024
@tobiu tobiu closed this as completed Feb 20, 2024
Client related tickets automation moved this from To do to Done Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant