-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add missing headers in the Table of Contents #1916
Conversation
@afercia @jasmussen do you think showing missing headings would be better than just highlighting the parent-less level? One concern is that it sort of implies that you should add the missing heading levels instead of changing the incorrect one. |
<div | ||
className={ classnames( | ||
'table-of-contents__item', | ||
`is-H${ level }`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from the original PR, but we should lowercase the class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 afe3467
I agree, the obvious course of action is to simply change the sub heading to be one less deep. Could we show a little exclamation mark or warning triangle or something, which on hover can suggest, perhaps even with a button, to fix the level? |
Let's start with highlighting with color and adding some text after the headline with "Should be Hx level". @sirreal would you be able to update this one? |
Or just change the text from "Missing header level" to "Skipped heading level"? |
What I mean is that presentation wise it's the difference between:
And:
|
@mtias I've reworked the component a bit to provide the incorrect level message. Here's what it looks like now: |
The messages look correct and informative to me. The HTML in the meta box is all It would be great if the outline report could update live while editing the post headings! Right now, after you make a change you need to save the post and refresh to see the outline updated. Not sure about technical details and maybe this could be merged as a first iteration" @sirreal thanks! and @mtias what's left to be done here? Re: the build failing, I think it's the PHP 5.2 thing and just needs to be rebased? |
It should update as soon as you focus-out from the heading you were writing. Does that work for you or you still need to save? |
Also, I think we can remove the "experimental" wording :) |
No, it doesn't for me. It does update when deleting a heading or adding a new one. |
I'll check that out. |
This is a functional first attempt at adding missing headers to the Table of Contents. The implementation appears to be correct but could use some clean up.
a0f5938
to
65f9cd1
Compare
Codecov Report
@@ Coverage Diff @@
## master #1916 +/- ##
==========================================
+ Coverage 22.15% 22.93% +0.77%
==========================================
Files 138 139 +1
Lines 4283 5136 +853
Branches 723 967 +244
==========================================
+ Hits 949 1178 +229
- Misses 2814 3250 +436
- Partials 520 708 +188
Continue to review full report at Codecov.
|
@sirreal thanks! I was just testing it and seems to update now. There's a small CSS issue in Safari and Edge (see screenshot below), and I'd like to try a couple changes to improve a11y (I'm trying them in a local branch):
From left to right: Safari, Edge, and (for reference) IE 11 N.B. the multiple scrollbars is a separate issue |
If I'm not wrong |
@afercia yes, I thought it didn't make a lot of sense to show it only for one header. My plan was to not show the section at all if you don't have any headers as well. |
@mtias OK that also avoids the need to handle singular/plural forms |
@@ -1,9 +1,8 @@ | |||
/** | |||
* External dependencies | |||
* External Dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"dependencies" should be lowercase
I went ahead:
Worth noting Safari + VoiceOver don't announce styled lists as lists, this is a Safari bug and the only way to fix it would be to add a redundant Firefox + NVDA announcing the number of items in the list: Chrome + VoiceOver announcing the number of items in the list: |
@sirreal feel free to merge when you think it's ready. |
Thanks both! |
Add missing headers to the Table of Contents.
Separate
TableOfContentsItem
into independent component.Closes #1903