diff --git a/src/controllers/ElementsController.php b/src/controllers/ElementsController.php index 6a5f5c9128f..512564f6deb 100644 --- a/src/controllers/ElementsController.php +++ b/src/controllers/ElementsController.php @@ -1634,9 +1634,14 @@ public function actionApplyDraft(): ?Response $this->requirePostRequest(); $elementsService = Craft::$app->getElements(); - /** @var Element|DraftBehavior|null $element */ + /** @var Element|DraftBehavior|Response|null $element */ $element = $this->_element(); + // this can happen if creating element via slideout, and we hit "create entry" before the autosave kicks in + if ($element instanceof Response) { + return $element; + } + if (!$element || !$element->getIsDraft()) { throw new BadRequestHttpException('No draft was identified by the request.'); }