silverstripe-asset-admin icon indicating copy to clipboard operation
silverstripe-asset-admin copied to clipboard

Can't delete image if image isn't on the current page

Open blueo opened this issue 4 years ago • 7 comments

To reproduce:

  1. have at least 2 pages of assets
  2. Select an image from the first page so it shows in the editor pane on the right
  3. notice here, clicking the popover menu and selecting 'Download File' will work
  4. advance to the next page using the arrows at the bottom of the asset view
  5. 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

blueo avatar Apr 23 '20 04:04 blueo

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.

maxime-rainville avatar May 28 '20 23:05 maxime-rainville

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?

blueo avatar May 28 '20 23:05 blueo

@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

maxime-rainville avatar May 29 '20 00:05 maxime-rainville

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.

clarkepaul avatar Jun 01 '20 23:06 clarkepaul

Accidentally fixed this problem with https://github.com/silverstripe/silverstripe-asset-admin/issues/1225

maxime-rainville avatar Jul 19 '21 06:07 maxime-rainville

Fix release in 1.8.3

maxime-rainville avatar Jul 20 '21 03:07 maxime-rainville

Actually, the download button is fixed but not the delete one.

maxime-rainville avatar Jul 20 '21 03:07 maxime-rainville