-
Notifications
You must be signed in to change notification settings - Fork 79
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
Upload field doesn't work in the asset admin context #1458
Comments
Have you tried this on CMS 5.2? There's a chance that silverstripe/silverstripe-admin#1694 will fix this - would require you changing to silverstripe/admin 2.2 to get the fix |
Hey @emteknetnz , I've retested this issue on The issue is still present. |
I've added same ACs to the cards. FYI I suspect this will not be a trivial fix. And we have to ask ourselves how to handle the recursive scenario where you try to edit a file inside an InserMediaModal and interact with a nested UploadField. It's highly likely this particular scenario will blow up in our face. So it might be that we say "no nested UploadField". Anyway, I've added this to our Monday refinement session. Maybe we need to do a Spike first before attempting a fix. Not sure. |
This is happening because the The All of the redux state and actions are shared between the To resolve this we'd need to split out the state for the upload field from the state for the main asset admin. I can't see an easy non-hacky way to do that. Possible ways forward
|
I'm not sure that would even work? Doesn't the redux store live in window.ss.store and it's not 'namespaced' to the react root? i.e. if you create 2x react roots they'll share the store? I'm only making assumptions here, I haven't tested. e.g. window.ss.store.getState()['assetAdmin'] returns an object with some things in it but it's not namespaced Maybe we could add an index "namespace" to 'assetAdmin'? to handle multiple versions of it? This whole seems very hard and messy |
Dunno, haven't investigated it, it was just a possible approach that might maybe possible work. Definitely wouldn't be my go-to. I'd probably prefer just not doing anything over doing that even if it works. |
Me too, maybe put a disclaimer somewhere in the docs that using an UploadField in AssetAdmin is known to be buggy? |
I don't think there's any way we can fix this without a substantial re-factor of asset-admin. I'm thinking we bump this up to CMS 6. My instinct would be to:
Most of that stuff should probably be done anyway to have a more solid architecture. Fixing this bug would just be the cherry on top. |
I've re-targeted this issue to the CMS 6 milestone. Our ability to address this issue will be contingent on whether we choose to prioritise an asset-admin refactor. |
Module version(s) affected
2.1.x-dev
Description
I'm trying to set up a simple
has_one
relation between files. The data setup part works as expected but when I useUploadField
the UI goes through some unexpected interactions (details below) and the selected asset is not saved. This doesn't happen when a different field is used, for example aDropdownField
.Tested this on vanilla install using
"silverstripe/recipe-cms": "5.x-dev",
How to reproduce
Data setup
Model
Form
Config
Test scenario:
Expected behaviour
I can see asset selection modal so I can choose Image A
Clicking insert will put the Image A into the Image B records via the ReplacementAsset relation. I then click save and the record gets updated.
Actual behaviour
The screen transitions into a read only version of the Image B edit form.
I can still interact with the upload field.
Clicking on the upload field will trigger the modal and I can select Image A.
Clicking insert button will navigate back to the edit version of the Image B edit form but the asset selection is lost so no changes are saved to the DDB record of Asset B.
Possible Solution
Managed to create workaround by setting up a separate model admin to allow the use of non-react edit form where the upload field works as expected.
Acceptance criteria
Notes
The text was updated successfully, but these errors were encountered: