Closed Bug 1590366 Opened 5 years ago Closed 5 years ago

Remove accessibility.heading-element-level-changes.enabled and code it guards

Categories

(Core :: Disability Access APIs, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: annevk, Assigned: emilio)

Details

Attachments

(1 file)

Basically, revert the part of bug 998590 that's not cleaning up code, as the resulting user experience was not great on too many sites (many h1s that were expected by the site and user to be level 1 becoming level 2). Unfortunate, but at least we now know what path to not take.

Flags: needinfo?(mzehe)
Flags: needinfo?(emilio)
Assignee: nobody → emilio
Flags: needinfo?(emilio)
Flags: needinfo?(mzehe)
Pushed by mzehe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f56a91cd47c6
Remove accessibility.heading-element-level-changes.enabled. r=MarcoZ
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72

Do we have a reference to the data mentioned in comment 0? I'm not seeing obvious bug reports linked to here or bug 998590...

Flags: needinfo?(emilio)

I think it was mostly feedback from Marco and the rest of our a11y team.

Flags: needinfo?(emilio)

Can that feedback be made public? It'd be good to see some URLs that were broken by this change.

Examples where h1 became h2 and that was frustrating were:

Headings on this page, levelled by the number in their tag name.

Bugzilla
  Quick Search
    Saved Searches
  Requests
Remove accessibility.heading-element-level-changes.enabled and code it guards
  Categories
    (Core :: Disability Access APIs, defect)
  Tracking
    (bug RESOLVED as FIXED for Firefox 72)
  People
    (Reporter: annevk, Assigned: emilio)
  References
  Details
  Crash Data
  Security
    (public)
  User Story
  Phabricator Revisions
    (1 active revision)
  Attachments
    (1 file)
    Description
    Updated
    Comment 1
    Updated
    Comment 2
    Comment 3
    Comment 4
    Comment 5
    Comment 6
    Comment 7
    Comment 8
    Comment 9

Two H1s, and comments appear under 'attachments' which isn't great. Could be worse.

If h1s get an extra level for every sectioning element they're within:

Bugzilla
  Quick Search
    Saved Searches
  Requests
  Remove accessibility.heading-element-level-changes.enabled and code it guards
  Categories
    (Core :: Disability Access APIs, defect)
  Tracking
    (bug RESOLVED as FIXED for Firefox 72)
  People
    (Reporter: annevk, Assigned: emilio)
  References
  Details
  Crash Data
  Security
    (public)
  User Story
  Phabricator Revisions
    (1 active revision)
  Attachments
    (1 file)
    Description
    Updated
    Comment 1
    Updated
    Comment 2
    Comment 3
    Comment 4
    Comment 5
    Comment 6
    Comment 7
    Comment 8
    Comment 9

Only 1 h1, but content is no longer under the heading of the bug title.

If all headings get an extra level for every sectioning element they're within:

Bugzilla
    Quick Search
        Saved Searches
    Requests
  Remove accessibility.heading-element-level-changes.enabled and code it guards
    Categories
      (Core :: Disability Access APIs, defect)
    Tracking
      (bug RESOLVED as FIXED for Firefox 72)
    People
      (Reporter: annevk, Assigned: emilio)
    References
    Details
    Crash Data
    Security
      (public)
    User Story
    Phabricator Revisions
      (1 active revision)
    Attachments
      (1 file)
      Description
      Updated
      Comment 1
      Updated
      Comment 2
      Comment 3
      Comment 4
      Comment 5
      Comment 6
      Comment 7
      Comment 8
      Comment 9

No more duplicate h1s. Content relating to the bug is correctly nested. Comments are still part of "attachments", but that was broken anyway. Some heading levels are skipped in the header, but that might not be a big deal?

I'm trying to figure out if we need to tweak the algorithm, or peruse <h> instead.

Here's how I figured out the heading levels. I realise it doesn't cater for <hgroup>.

function getParentSections(el) {
  const sectionEls = new Set(['nav', 'article', 'section', 'aside', 'blockquote', 'figure', 'td', 'details', 'fieldset'].map(n => n.toUpperCase()));
  let node = el;
  let num = 0;
  while (node = node.parentNode) {
    if (sectionEls.has(node.tagName)) num++;
  }
  return num;
}

function getTagHeadingLevels(useSections) {
  const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
  return [...headings].map(heading => {
    let headingNumber = Number(heading.tagName.slice(1));
    if (useSections === 'all' || (useSections === 'h1' && headingNumber === 1)) {
      headingNumber += getParentSections(heading);
    }

    const indent = '  '.repeat(headingNumber - 1);
    return indent + heading.textContent.trim();
  }).join('\n');
}
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: