silverstripe-asset-admin
silverstripe-asset-admin copied to clipboard
Can't delete image if image isn't on the current page
To reproduce:
- have at least 2 pages of assets
- Select an image from the first page so it shows in the editor pane on the right
- notice here, clicking the popover menu and selecting 'Download File' will work
- advance to the next page using the arrows at the bottom of the asset view
- attempt to download the file again - nothing appears to happen and an exception is thrown in the console (below)
the exception is (with dev files):
TypeError: this.props.file is undefined 2 Editor.js:130:4
downloadFile Editor.js:130
handleAction Editor.js:50
handleAction self-hosted:844
handleAction FormBuilder.js:191
handleAction self-hosted:844
handleClick FormAction.js:156
handleClick self-hosted:844
React 17
bind_applyFunctionN self-hosted:1042
dispatchEvent self-hosted:1005
unstable_runWithPriority scheduler.development.js:697
React 4
dispatchDiscreteEvent self-hosted:948
(Async: EventListener.handleEvent)
addEventListener index.js:190
React 20
initReactRouter BootRoutes.js:111
start BootRoutes.js:55
_callee$/< index.js:54
load buildInjectorContainer.js:78
_callee$/< index.js:67
(Async: setTimeout handler)
_callee$ index.js:67
Babel 9
(Async: EventHandlerNonNull)
js index.js:69
Webpack 5
it seems file object is removed from the Editor props when the item is no longer in the gallery view.
tested on Silverstripe 4.5.1 with silverstripe/asset-admin 1.5.1
Pull request
- [x] https://github.com/silverstripe/silverstripe-asset-admin/issues/1225
Managed to replicate.
Looks like the problem is that when you swap page, the file you are currently editing looses its graphql context. So the editor doesn't know what the file ID is anymore. Looks like other action are broken as well, like Delete. Interestingly, Save/Publish work just fine.
I'm thinking, one fix here is probably to close the editor when you change page. There's precedent for that: when you change folder it will close the editor, so it would arguably make sense to do the same thing when you change page.
it might be slightly unexpected to have that close when navigating a page/searching. I think my preference would be that it stays open. Could the editor keep its state independent of the gallery?
@silverstripeux Got any views on this? Closing the edit panel on page navigation would be an easy fix, but it might not be the best thing UX wise.
Here's a video illustrating what we're talking about https://youtu.be/X2CBGHHPnVY
I think a user would expect it to stay open until a different file is selected, regardless if it was on the same page or not. Sorry, I think the best fix is not the easiest.
Accidentally fixed this problem with https://github.com/silverstripe/silverstripe-asset-admin/issues/1225
Fix release in 1.8.3
Actually, the download button is fixed but not the delete one.