Problem/Motivation
Main problem: The 2.0.1 release included new message stating that "Table using uswds sortable does not have a caption, which is required for accessiblity" (sic). While the code checks for the presence of the usa-table--sortable
tag, it doesn't take that check into account when presenting the error message.
Secondarily, a message like this probably should be a warning, and show to the user editing the page when trying to save the page (entity), not to anonymous users browsing the page.
Tertiarily: "accessibility" is misspelled.
Quaternarily: PHP Docs state that strpos()
is faster and consumes less memory than strstr()
, and so presumably stripos()
is similarly faster than stristr()
.
Quinarily: searching for the string "table" may bring many false positives. I suggest changing the search to at least match '<table'
, which will still catch all TABLE tags without catching generic uses of the word table.
Senarily: If no "usa-table--sortable"
tables are found, there is no need to do any more processing in this filter. Why not return immediately?
All but the second are trivial to implement. My MR will contain fixes for all of the rest.
Steps to reproduce
1. Add/enable FilterUswdsTableSortable to a filter using CKEditor 5.
2. Create content using this filter (node, in my case).
3. Create a table inside CKEditor 5 that isn't sortable (i.e., a table without the "usa-table--sortable" class).
4. Save the content.
5. Verify error message.
6. Browse the page as an anonymous user.
7. Verify error message shows to anonymous users.
8. Browse any pages with this filter and the word "table" anywhere in the text.
9. Verify error message shows.
Seriously. All you have to do is write the word "table" in the body of the text, save it, and you will see this error message. You could be writing about vegetables and this error message would show to everyone. This error message is right now showing to all users on all USWDS-ckeditor sites with this filter enabled, regardless of how long ago the content was written. I'm surprised it's not showing up on Google and USA.gov searches yet.
Proposed resolution
Summarized above.
Remaining tasks
Move the message to an edit screen, or otherwise hide the error message from the casual viewer of the page.
User interface changes
None.
API changes
None.
Data model changes
None.