SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.96k stars 1.24k forks source link

sap.m.upload.UploadSet duplicate ID error when adding item after deleting an item #3939

Closed swayongshen closed 2 months ago

swayongshen commented 10 months ago

OpenUI5 version: 1.120.0

Browser/version (+device/version): Chrome, MacOS

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

URL (minimal example if possible): -

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

Steps to reproduce the problem:

  1. UploadSet (id='modelFiles') items aggregation is binded to an array in a JSON model, this array has 2 elements, so UploadSet contains 2 items.
  2. Delete first item and update the JSON model
  3. Upload a new item and update the JSON model
  4. The following error because the second item that still exists previously had an index of 1 and the newly added item also has index of 1
image
swayongshen commented 10 months ago

Current workaround:

  1. Set the array to empty ([]) in the model
  2. Set the array in the model to be the array after the first item is deleted (so that the index of the item that remains will be now set to 0 instead of 1).
  3. Any new item can take the index 1 without clashing with the item that remains.
NHristov-sap commented 10 months ago

Hi @swayongshen ,

Can you please provide a live example (jsbin or similar) that demonstrates the issue?

Best Regards, Nikolay Hristov

swayongshen commented 9 months ago

Hi @NHristov-sap please refer to this https://jsfiddle.net/yongshenswa/0L6v5hs4/31/

swayongshen commented 9 months ago

Also, do we have any idea about this error? It even exists in the Demo sample https://sapui5.hana.ondemand.com/#/entity/sap.m.upload.UploadSet/sample/sap.m.sample.UploadSet

image
flovogt commented 9 months ago

Thanks a lot @swayongshen. I have created an internal incident DINC0034917 to follow-up on this one. The responsible team will get in touch with you here on github.

flovogt commented 9 months ago

Also, do we have any idea about this error? It even exists in the Demo sample https://sapui5.hana.ondemand.com/#/entity/sap.m.upload.UploadSet/sample/sap.m.sample.UploadSet image

You can ignore that one. The control owner has to change some control internal functionality.

neoruien commented 9 months ago

Hi @flovogt, may I know if there are any updates regarding this issue?

I was getting these errors and warnings:

image

Then I imported both DataType and UploadSetItem and added this line of code:

    this.uploadSet = this.byId('modelFiles') as UploadSet;
    DataType.registerEnum('sap.m.upload.UploadSetItem', UploadSetItem); // added this

The errors have been resolved, but the warnings linger. I was wondering if DataType.registerEnum is the correct way to resolve the errors, and if the warnings can be fixed?

codeworrior commented 9 months ago

The error message The type 'xyz' was accessed via global. Defining enums via globals is deprecated. Please require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' is unfortunately quite misleading.

Its suggestion part only applies, if the type 'xyz' is indeed an enum. This is not the case for 'sap.m.upload.UploadSetItem' .

Therefore, calling DataType.registerEnum is wrong in this place. Please remove that code again!

The real issue is named by the warning line: `sap.m.upload.UploadSetItem' is not a valid data type. This had to be fixed in the code of the UploadSetItem control: 30d37ba15633773a1e2dd9485a03f9ea6a410e4f fixes this and will be part of the upcoming 1.121 release. As far as I can see, it also has been down ported to 1.120 as 1c08857fb8a22e6785c5a688fbedc7e60eeaf181 and should e part of the next patch in 1.120.

The misleading error message meanwhile also has been reworded. It now reads [DEPRECATED] The type 'xyz' was accessed via globals. Defining types via globals is deprecated. In case the referenced type is an enum: require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' API. In case the referenced type is non-primitive, please note that only primitive types (and those derived from them) are supported for ManagedObject properties. If the given type is an interface or a subclass of ManagedObject, you can define a "0..1" aggregation instead of a property

neoruien commented 9 months ago

Hi @codeworrior, thank you for your response! May I know when will the next patch in 1.120 be released?

flovogt commented 9 months ago

planned for next month

rd-janis-burbach commented 2 months ago

@flovogt Are there any updates? When will the patch arrive? I just integrated the Uploadset into an application and the role out for this app is planned for end of September.

flovogt commented 2 months ago

The error message The type 'xyz' was accessed via global. Defining enums via globals is deprecated. Please require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' is unfortunately quite misleading.

Its suggestion part only applies, if the type 'xyz' is indeed an enum. This is not the case for 'sap.m.upload.UploadSetItem' .

Therefore, calling DataType.registerEnum is wrong in this place. Please remove that code again!

The real issue is named by the warning line: `sap.m.upload.UploadSetItem' is not a valid data type. This had to be fixed in the code of the UploadSetItem control: 30d37ba fixes this and will be part of the upcoming 1.121 release. As far as I can see, it also has been down ported to 1.120 as 1c08857 and should e part of the next patch in 1.120.

The misleading error message meanwhile also has been reworded. It now reads [DEPRECATED] The type 'xyz' was accessed via globals. Defining types via globals is deprecated. In case the referenced type is an enum: require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' API. In case the referenced type is non-primitive, please note that only primitive types (and those derived from them) are supported for ManagedObject properties. If the given type is an interface or a subclass of ManagedObject, you can define a "0..1" aggregation instead of a property

The mentioned fix was released with UI5 1.120.4.

The overall issue is still open and not fixed.