Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixes #18872 currentValue is not current in Umbraco.BlockList element properties #18976

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

PeterKvayt
Copy link
Contributor

@PeterKvayt PeterKvayt commented Apr 8, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Fixes #18872

Here, I am adding additional logic to include in processing the current value.

In the original implementation umbraco set the edited and current value in the following way:
изображение

As you can see, the current value was always the same and equal to edited value. This leads to unexpected behavior for property editors, that rely on current value.

In this PR I am parsing currentValue:
изображение

and then creating a mapping for edited and current data. Mapping allows us to determine whether the value was cleared or removed (it is if edited was null), or changed (it is if edited and current are not null), or just created (it is if current is null).
In any case, it would be processed in the same way.

Also I have changed the following piece of code:
изображение

So now it is now "fake" content property data object, it is a "real".

Also there is an additional fix for FileUploadPropertyValueEditor. The fix covers the case when the current value is not just a string, but presented as json string with src value (I have faced with this case during testing).


This item has been added to our backlog AB#51895

Copy link

github-actions bot commented Apr 8, 2025

Hi there @PeterKvayt, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@PeterKvayt
Copy link
Contributor Author

I can't understand what the issue is with the failed check.

@nielslyngsoe nielslyngsoe requested a review from AndyButland April 9, 2025 09:57
@nul800sebastiaan nul800sebastiaan changed the title Temp/18872 Fixes #18872 currentValue is not current in Umbraco.BlockList element properties Apr 10, 2025
@nielslyngsoe nielslyngsoe added the state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks label Apr 14, 2025
@AndyButland
Copy link
Contributor

AndyButland commented Apr 17, 2025

Hi @PeterKvayt - I'll try to give this a review next week. Before I do though, are you able to update here or on the issue with a practical example of the problem the code concern you've found please? I do agree it looks incorrect, and it seems we should expect a property to behave the same with a block list or when used directly on a content item, but it would be good to understand what "real world" problem it is causing. Partly for prioritisation, and partly to be able to verify that the PR does resolve the issue. Thanks.

I can't understand what the issue is with the failed check.

This is due to the change you have made in to the signature of this method: Umbraco.Cms.Core.PropertyEditors.BlockValuePropertyValueEditorBase<TValue, TLayout>.MapBlockValueFromEditor(TValue) - as it's protected it's part of a public API, so we can't change this other than perhaps in a major version bump. So likely we would need to keep it, introduce a new method and obsolete the original.

@PeterKvayt
Copy link
Contributor Author

Hi @AndyButland!
Thanks for the reply.
I will provide a practical example a little bit later (hopefully this week or at the beginning of next week).

@PeterKvayt
Copy link
Contributor Author

Okay, so I have a few issues related to this PR:

I encountered the following situation: Initially, I was using the standard document type with the default Umbraco.FileUpload property (which, at the time, was not part of a Block List). Later, I needed to create a custom FileUpload property editor with an additional setting to manage a prefix for the uploaded file path. At that point, I started using my custom FileUpload property editor.

Eventually, I needed to use this custom editor within a Block List element property. Since it was a custom property editor, it was allowed to be used within Block List elements — unlike the default Umbraco.FileUpload, which isn't supported in that context. I resolved the issues related to using Umbraco.FileUpload in Block Lists (see: #18755).

As a result, I now have a custom FileUpload property editor that can be used inside Block List elements. It also handles file deletion from storage properly, as we're addressing the issue related to invalid current values that previously caused problems.

@AndyButland
Copy link
Contributor

AndyButland commented Apr 28, 2025

Hi @PeterKvayt - I've been reviewing this today and think it's looking good. Working as expected when I step through and I've resolved the breaking change and added some unit tests now to verify the behaviour.

I've also enabled the file upload property to be used in the block list - which, from what I read above, has been your aim with the issues you've raised and this PR. Having asked around it seems that this was a restriction in Umbraco 13 but doesn't need to be in 15+, so in theory it should work as expected (particularly with the change you've proposed here).

Would you mind taking a look over my changes and see if you can find any issue with the use of the file upload in the block list (or in the normal use as a property directly on a document type) please? Then if all looks good to you I think we can bring this in.

@iOvergaard iOvergaard changed the base branch from contrib to main May 5, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"currentValue" is not current in Umbraco.BlockList element properties
3 participants