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

opening page converts all table rows into table header rows #1087

Open
pdpinch opened this issue Mar 3, 2022 · 2 comments
Open

opening page converts all table rows into table header rows #1087

pdpinch opened this issue Mar 3, 2022 · 2 comments

Comments

@pdpinch
Copy link
Member

pdpinch commented Mar 3, 2022

Steps to Reproduce

  1. Take a look at this course markdown in github: https://github.mit.edu/ocw-content-rc/24.914-spring-2019/blob/main/content/pages/assignments/what-is-ae-tensing.md . Note that the table has two {{< theadopen >}}...{{< thclose >}} at the top.
  2. Open the corresponding page in studio-rc, https://ocw-studio-rc.odl.mit.edu/sites/24-914-language-variation-and-change-spring-2019/type/page/edit/e4d20a86-179f-459c-2c2c-3321342d0a2c/

Expected Behavior

  • Header rows should stay header rows, regular rows should stay regular rows

Actual Behavior

  • Every row looks like a header row, with bold text and shaded background
  • don't publish -- but if you did, you find every cell renders bold (but no shaded background)
@mbertrand mbertrand assigned mbertrand and unassigned mbertrand Mar 9, 2022
@mbertrand mbertrand self-assigned this Mar 17, 2022
@mbertrand
Copy link
Member

mbertrand commented Mar 17, 2022

This seems to be caused by CKEditor's default behavior for implementing row headers and column headers.

  • If any cell in column 1 is a <th> element, then all <td> elements in that column are converted to <th>
  • if a cell in column 2 in the same row as above or any subsequent row is a <th>, then all <td> elements in column 2 are converted to <th>, and so on

What I think is the relevant code is here:
SetHeaderColumnCommand

SetHeaderRowCommand

tableHeadingsRefreshHandler

At this point I'm not sure how to override/disable the above, and doing so might interfere with the 'Insert Header Row' and 'Insert Header Column' tools in the table editor UI.

@mbertrand mbertrand removed their assignment Mar 17, 2022
@ChristopherChudzicki ChristopherChudzicki self-assigned this Apr 25, 2022
@ChristopherChudzicki
Copy link
Contributor

@pdpinch Echoing Matt's comment above, I think this behavior is limitation/bug in CKEditor:

  • first M (possibly 0) rows can be headers
  • first N (possibly 0) columns can be headers
  • but you can't have non-consecutive header rows/columns

This clip is from https://ckeditor.com/ckeditor-5/demo/, not Studio:

table_header_issue.mov

Documented in the links Matt...

SetHeaderColumnCommand Note: All preceding columns will also become headers. If the current column is already a header, executing this command will make it a regular column back again (including the following columns).
SetHeaderRowCommand Note: All preceding rows will also become headers. If the current row is already a header, executing this command will make it a regular row back again (including the following rows).

Two separate issues

  1. Affects new content authoring: The above behavior ("...All preceding columns will also become headers.", etc) is weird and maybe surprising to authors. Seems hard to do anything about since this is documented CKEditor behavior.
  2. Loading old tables with random <th /> sprinkled in can mess them up: Only an issue for imported courses.

I am confident that (2) is somewhat rare: about 72 tables across 44 pages, listed here https://docs.google.com/spreadsheets/d/1iLXs3QBVxk84rT0IQNJq05DffxhdGMDbDejGY4qk6w4/edit?usp=sharing (72 is more than I told you this morning on zoom; I missed the second bullet below.)

OCW has 10411 tables

  • 9369 of those start with a header, <table><thead>...</thead>...stuff...</table>
    • Problematic: 23 of these have th outside the first <thead>. (Sometimes the table has multiple theads)
      • of those 23, three are a single header column, like this and are not problematic
    • the rest do not and seem safe
  • 1036 have no <thead> at all
    • Problematic: 52 of these do have header cells
    • the rest do not and seem safe
  • 6 tables evaded my classification

Somewhat related CKEditor issue: ckeditor/ckeditor5#11536 Not entirely related; seems to be above SUBSEQUENT columns becoming headers erroneously.

@pdpinch pdpinch removed their assignment Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants