Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyMCE with HTML5 Required attribute set won't allow save - no on-page error message #1893

Closed
BrendonKoz opened this issue Mar 5, 2024 · 5 comments

Comments

@BrendonKoz
Copy link

Short description of the issue

When applying both "required" attributes to a TinyMCE field (Required?, and Also use HTML5 "required" attribute?), any pages created (only tested on new page) using a template with this configuration on that field will fail to save. Removing the HTML5 required attribute and relying on ProcessWire's processing of the form to verify the required field has been filled in appropriately.

Expected behavior

The expected behavior is that PW will identify that the richtext editor field has proper content/value and the page can be saved.

Actual behavior

The page will not save. The browser developer Console fills the page with is not focusable error messages. The page auto-scrolls to the first (if there are multiple) TinyMCE field on the template, but there are no visible error messages on the page. (Using Firefox v124.0b6), should it matter.)

Optional: Screenshots/Links that demonstrate the issue

image

Optional: Suggestion for a possible fix

A temporary fix is to disable the Also use HTML5 "required" attribute? setting for any/all TinyMCE fields, if set.

Possibly related to #799 (comment) ?

Steps to reproduce the issue

  1. Setup a brand new ProcessWire installation (I used the Master branch).
  2. Create a TinyMCE field
    3 In the "Input" tab of the TinyMCE field, check/enable the Required? attribute, and once set, also set the Also check/enable the HTML5 "required" attribute? field of the TinyMCE field's settings
  3. Add this configured TinyMCE field to a template
  4. Create a new page using the template this field was added to
  5. Fill out the required content on the newly required page and attempt to save or publish

Setup/Environment

Software Version
ProcessWire 3.0.229
PHP 8.2.1
Webserver Apache/2.4.54 (Unix) OpenSSL/3.0.7
MySQL Server 8.0.32
MySQL Client mysqlnd 8.2.1
@matjazpotocnik
Copy link
Collaborator

TinyMCE adds style="display:none" to the <textarea class="FieldtypeTextarea ..." id="Inputfield_body" name="body" rows="5" required="required" style="display:none" aria-hidden="true"></textarea> making it not focusable, not clickable. So I added:

.InputfieldTinyMCE textarea:required {
    display: block !important;
    position: absolute;
    width: 1px;
    overflow: hidden;
}

ryancramerdesign added a commit to processwire/processwire that referenced this issue Mar 22, 2024
@ryancramerdesign
Copy link
Member

@BrendonKoz Thanks, I didn't realize the HTML5 option was there. It's not supposed to be there because of course TinyMCE is not an HTML5 input type. I have pushed an update that removes that configuration setting.

@matjazpotocnik I'm not sure I understand what that does? Does the focus event transfer to the TinyMCE input somehow?

@matjazpotocnik
Copy link
Collaborator

With the first rule, the textarea is made visible again in DOM, and other rules make the textarea 1 px wide, just enough to be focusable:

image

@ryancramerdesign
Copy link
Member

@matjazpotocnik Thanks, that's a creative solution, I like it! :)

Though I'm not confident that it would survive across browsers and also wonder if the user starts typing, would it then go directly into the 1px wide textarea, bypassing TinyMCE. So I'm thinking we should probably just stick with disabling the HTML5 required option for TinyMCE, to play it safe.

@matjazpotocnik
Copy link
Collaborator

@ryancramerdesign I still get errors about an unfocusable element. I had to delete "requiredAttr":1 from the data json in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants