What happened?
Description
- Clicking away or clicking "cancel" while creating an entry in a drawer for a matrix field works as expected (cancelling the creation of that block), but clicking the "add block" button again will throw a "User not authorized to create this element." error.
Steps to reproduce
- Create a matrix field, with at least one entry type.
- Set a
Max Entries value (ie: 1 or 2).
- Set the view mode to "As an element index" or "As cards"
- Add the matrix field to another field layout for testing.
- Create or edit an entry with the matrix field.
- Click the button to add a new block to the matrix field
- Once the entry create drawer opens, cancel the creation of the entry.
- Repeat steps 6 and 7 until you have done so once-more than the "Max Entries" value.
Expected behavior
- I should be able to cancel and/or add a block from the matrix field as many times as I want.
Actual behavior
- Craft throws an error stating "User not authorized to create this element.", and the element cannot be recreated.
- If the
Max Entries value is greater than 1, one of the "canceled" entries may appear as a draft entry after reloading the page, or attempting to save.
- If the matrix block is nested in the field layout of another matrix block I occasionally have to delete and create the parent block to resolve the error.
Screen captures:

Stack Trace:
yii\web\ForbiddenHttpException: User not authorized to create this element. in craft/vendor/craftcms/cms/src/controllers/ElementsController.php:2186
Stack trace:
#0 craft/vendor/craftcms/cms/src/controllers/ElementsController.php(194): craft\controllers\ElementsController->_createElement()
#1 [internal function]: craft\controllers\ElementsController->actionCreate()
#2 craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#4 craft/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('create', Array)
#5 craft/vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction('elements/create', Array)
#6 craft/vendor/craftcms/cms/src/web/Application.php(650): craft\web\Application->runAction('elements/create', Array)
#7 craft/vendor/craftcms/cms/src/web/Application.php(311): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#8 craft/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 craft/web/index.php(12): yii\base\Application->run()
#10 {main}
Craft CMS version
Craft Pro 5.1.3
PHP version
8.3.4
Operating system and version
MacOS Sonoma 14.4.1 (23E224)
Database type and version
MySQL 8.3.0
Image driver and version
GD 8.3.4
Installed plugins and versions
What happened?
Description
Steps to reproduce
Max Entriesvalue (ie: 1 or 2).Expected behavior
Actual behavior
Max Entriesvalue is greater than 1, one of the "canceled" entries may appear as a draft entry after reloading the page, or attempting to save.Screen captures:
Stack Trace:
Craft CMS version
Craft Pro 5.1.3
PHP version
8.3.4
Operating system and version
MacOS Sonoma 14.4.1 (23E224)
Database type and version
MySQL 8.3.0
Image driver and version
GD 8.3.4
Installed plugins and versions