From 11ddae4661b100a7cd384283ca57f1669db505ed Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Tue, 4 Jun 2024 09:36:33 +0100 Subject: [PATCH] apply draft - element can be a response --- src/controllers/ElementsController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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.'); }