New page with required text field cannot be saved

Created on 19 October 2023, about 1 year ago

Problem/Motivation

A content type where the "Long text" field is marked as 'required' cannot be saved - the save button just does nothing other than switch you back to the main settings window if it's open. No submission is made.

With zero other leads to go on, I went digging into gutenberg.js and found that the checkValidity call was returning false on the form (~line 326). Some debugging later revealed that it was a hidden textarea that was apparently marked as required, apparently it's the textarea that's supposed to hold the actual content? I guess gutenberg updates the content in some other way normally?

It'd also be nice if there was some way of returning an actual error in this scenario, rather than just doing nothing at all.

Interestingly, existing pages can be edited successfully. Possibly because they've already got content in the relevant (hidden) textarea?

There's a load of old bugs that look like the same issue, but they're all closed as fixed, so I must assume that this is a new issue...

If relevant:
Drupal: 9.5.11
PHP 8.1.24

Steps to reproduce

1. Create a content type
2. Add a long text field, mark it as required
3. Enable Gutenberg
4. Try to create a new content type
5. Observe that the save button appears to do nothing

Workarounds:
* Set some sort of dummy default content - though that creates an "undefined" HTML block that needs to be deleted. Maybe some amount of div tags in the appropriate format would fool gutenberg into thinking it's an existing empty block?
* Unset required tag on the field

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.8

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024