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

MultiComboBox inside table not working as expected during deletion, selected keys are updated with the keys of deleted row in the model #4162

Open
albertbolt1 opened this issue Nov 14, 2024 · 1 comment

Comments

@albertbolt1
Copy link

OpenUI5 version: 1.129.0

Browser/version (+device/version): google chrome

Any other tested browsers/devices(OK/FAIL): FAIL

URL (minimal example if possible):

745391

User/password (if required and possible - do not post any confidential information here):

not required

Steps to reproduce the problem:

  1. Run the snippix provided
  2. Delete the first entry in the table
  3. The selected keys of other entries in the multi combo box vanish
  4. While deleting the row I splice the json data based on the index of the row to be deleted
  5. I save the remaining data back in the model
  6. after saving the data in the model changes ( not the data that I asked it to save)

What is the expected result?

  1. The selection of the remaining multi combo boxes should be retained

What happens instead?

  1. The selection is cleared because the data I ask the model to save is not the same data it saves

Any other information? (attach screenshot if possible)
The data I want the model to save.
After deleting the first row, second row should have selected keys as 4,5,6 but after saving the data, the data is changed and the selected keys are 1,2,3 which are of the row which is deleted, because of this all the keys which were previously selected are being deleted
image

The same thing happens with second row, the keys should be retained and not deleted according to my model.

Wanted to know why the selectedKeys are being updated from the data of the deleted row and if there is a way to prevent this from happening.

@dobrinyonkov dobrinyonkov self-assigned this Nov 15, 2024
@dobrinyonkov
Copy link
Contributor

Hello @albertbolt1,

I suspect this issue has something with the order UI5 updates the controls upon bindings when a row is deleted (could also be something else). This may be causing the MultiComboBox to temporarily retain the binding context of the deleted row, resulting in mismatched selectedKeys.

The team has been informed about this behavior and will investigate further. They will get back to you with updates. Internal reference: DINC0334625

While you wait, and if this is urgent, you can try the following workaround:

Clear and Reset the Model
Before updating the model, clear it to ensure all bindings are reset:

oData.items.splice(iIndex, 1);
oModel.setData({});  
oModel.setData(oData);  

Create and Bind a New JSONModel
Instead of updating the existing model, create a new instance and bind it to your view:

oData.items.splice(iIndex, 1);
var oNewModel = new JSONModel(JSON.parse(JSON.stringify(oData)));
this.getView().setModel(oNewModel);

These solutions should help retain the selectedKeys in the MultiComboBox until a permanent fix is available. Let me know if you need help implementing any of these!

Kind Regards,
Dobrin

@dobrinyonkov dobrinyonkov removed their assignment Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants