Drupal 8 Preview button not working

1.6k Views Asked by At

When using a custom front-end theme, the preview button for my content stops working. It just redirects to the content overview page.

Am I missing something in my theme that allows me to use the 'preview' function?

2

There are 2 best solutions below

0
Jason Ruyle On

You most likely have the ?destination=admin/content in your URL. This is a core bug. The current discussion can be read at:

https://www.drupal.org/node/2325463

2
M.D. On

Jason Ruyle's answer is correct, I had the same problem and solved it by adding this code to my module:

use Drupal\Core\Entity\EntityInterface;

function my_module_entity_operation_alter(array &$operations, EntityInterface $entity) {
    if (isset($operations['edit']['query'])) {
        unset($operations['edit']['query']['destination']);
    }
    return $operations;
}

The code could also be improved to target the right entities, if needed.