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

255: Add anchor links to headings #296

Merged
merged 15 commits into from
May 31, 2024
Merged

Conversation

erinysong
Copy link
Contributor

@erinysong erinysong commented May 16, 2024

Ticket

Resolves #255

Changes

  • Add anchor links to Headers 2-6.
  • Underline anchor linked headers on hover.
  • Remove special characters from all anchor links. This can also be adjusted flexibly in the future if necessary.

Accessibility
Anchor link text aligns closely with actual header text. Anchor link format matches the same style as MDN and HTTP Archive.

Miscellaneous Notes

  • Anchor links currently do not include icons but the library we use to anchor our headers allow flexible options for anchor link format.
  • Anchor links only jump to the clicked header and do not automatically copy the link to the clipboard (the user must manually copy the URL in order to copy the link URL). If we want our anchor links to also copy to clipboard, I can update this PR to do so.

Context for reviewers

Setup

Sandbox testing
Anchor links can be tested on pages populating the Help page, About page, and Domains page.

  • Go to this PR's cloud pages site and test that clicking on any h2-h6 headers successfully jumps to the clicked header and updates the URL with the header's anchor link, usually the header's title text though some exceptions exist (e.g., we maintain Help FAQ renaming long headers' anchor links to shorter keywords summarizing the question)
  • Test that the navigation menu also correctly navigates the user to the correct anchor linked header.

Local testing
Test that the above sandbox testing also succeeds in the local environment.

Code Review Verification Steps

As the original developer, I have

Satisfied acceptance criteria and met development standards

  • Met the acceptance criteria, or will meet them in a subsequent PR
  • Created/modified automated tests
  • Added at least 2 developers as PR reviewers (only 1 will need to approve)
  • Messaged on Slack or in standup to notify the team that a PR is ready for review
  • Changes to “how we do things” are documented in READMEs and or onboarding guide
  • If any model was updated to modify/add/delete columns, makemigrations was ran and the assoicated migrations file has been commited.

Ensured code standards are met (Original Developer)

  • All new functions and methods are commented using plain language
  • Did dependency updates in Pipfile also get changed in requirements.txt?
  • Interactions with external systems are wrapped in try/except
  • Error handling exists for unusual or missing values

Validated user-facing changes (if applicable)

  • New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
  • Checked keyboard navigability
  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)
  • Add at least 1 designer as PR reviewer

As a code reviewer, I have

Reviewed, tested, and left feedback about the changes

  • Pulled this branch locally and tested it
  • Reviewed this code and left comments
  • Checked that all code is adequately covered by tests
  • Made it clear which comments need to be addressed before this work is merged
  • If any model was updated to modify/add/delete columns, makemigrations was ran and the assoicated migrations file has been commited.

Ensured code standards are met (Code reviewer)

  • All new functions and methods are commented using plain language
  • Interactions with external systems are wrapped in try/except
  • Error handling exists for unusual or missing values
  • (Rarely needed) Did dependency updates in Pipfile also get changed in requirements.txt?

Validated user-facing changes as a developer

  • New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing

  • Checked keyboard navigability

  • Meets all designs and user flows provided by design/product

  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)

  • Tested with multiple browsers, the suggestion is to use ones that the developer didn't (check off which ones were used)

    • Chrome
    • Microsoft Edge
    • FireFox
    • Safari
  • (Rarely needed) Tested as both an analyst and applicant user

Note: Multiple code reviewers can share the checklists above, a second reviewers should not make a duplicate checklist

As a designer reviewer, I have

Verified that the changes match the design intention

  • Checked that the design translated visually
  • Checked behavior
  • Checked different states (empty, one, some, error)
  • Checked for landmarks, page heading structure, and links
  • Tried to break the intended flow

Validated user-facing changes as a designer

  • Checked keyboard navigability

  • Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)

  • Tested with multiple browsers (check off which ones were used)

    • Chrome
    • Microsoft Edge
    • FireFox
    • Safari
  • (Rarely needed) Tested as both an analyst and applicant user

Screenshots

Copy link

@rileyorr rileyorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erinysong overall this looks great!

The only thing I noticed was when I tested with VoiceOver on the About page's 'What we don't offer' header it read it out as "don T' (dawn tee) instead of 'don't' when I had it read out the url in the url bar. Since we're customizing some of the anchor tags on the FAQ page I wonder if we could write out 'do-not' instead of 'don-t'. Let me know if that's a light lift. Otherwise, looks good to me.

cc @Katherine-Osos in case you have any thoughts on this as well

Copy link
Member

@h-m-f-t h-m-f-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, works well!

@erinysong
Copy link
Contributor Author

@rileyorr Thank you for the feedback and that's a great suggestion on the contraction words! It's a light change from just editing the link name of those specific headers, so I can push a change right now to update those!

@erinysong
Copy link
Contributor Author

Just pushed an update to our headers with contractions! In case it's helpful to put it here, if we want to customize the URLs for headers, we would format them using the following:

Before: Default Header
## Header Name

After: Customize Header URL
## Header Name {#custom-url-name}

This is the standard way to change URL's in markdown, and the library we use to generate anchor links for our headers also accepts this format to infer that we want to override any default anchor link formatting for a header

Comment on lines +135 to +137
permalink: markdownItAnchor.permalink.headerLink({
safariReaderFix: true,
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Q) Just out of curiosity, what does this do? I'm unfamiliar with markdownItAnchor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a flag built into markdownItAnchor to patch an issue with Safari's browser settings affecting markdown! I believe the developers added it in response to someone posting about the Safari bug
image

@@ -13,7 +13,7 @@
- Stay informed about [domain security best practices](../../domains/security).
- Edit information about your contacts or your domain (like changes to your DNS settings) anytime.

### What we don’t offer
### What we don’t offer {#what-we-do-not-offer}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@@ -42,7 +42,7 @@ Avoid using the following in your .gov domain name:
- [Judicial branch federal agencies](#judicial-branch-federal-agencies)
- [Legislative branch federal agencies](#legislative-branch-federal-agencies)
- [Interstate organizations](#interstate-organizations)
- [U.S. states and territories](#u.s.-states-and-territories)
- [U.S. states and territories](#u-s-states-and-territories)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [U.S. states and territories](#u-s-states-and-territories)
- [U.S. states and territories](#us-states-and-territories)

I would recommend this instead! At least for me, if I had no context of what this link contained, I'd be confused by the dash separator

Copy link
Contributor Author

@erinysong erinysong May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point on this! I think the intention behind this was so that screen readers could properly read U.S. as separate letters but can also see how this might introduce more complex anchor links -- since this got design approval I'm assuming that separating US into u-s is effective, but I can defer to @cisagov/gov-designers on their opinion on this

Comment on lines +39 to +40
- [U.S. Senate](#u-s-senate)
- [U.S. House of Representatives](#u-s-house-of-representatives)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [U.S. Senate](#u-s-senate)
- [U.S. House of Representatives](#u-s-house-of-representatives)
- [U.S. Senate](#us-senate)
- [U.S. House of Representatives](#us-house-of-representatives)

- [U.S. states and territories](#u.s.-states-and-territories)
- [States and territories: executive branch](#states-and-territories%3A-executive-branch)
- [States and territories: judicial and legislative branches](#states-and-territories%3A-judicial-and-legislative-branches)
- [U.S. states and territories](#u-s-states-and-territories)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [U.S. states and territories](#u-s-states-and-territories)
- [U.S. states and territories](#us-states-and-territories)

- [Get familiar with domain security best practices](#get-familiar-with-domain-security-best-practices)
- [Develop a communications plan](#develop-a-communications-plan)
- [Find out if you’re eligible for financial assistance](#find-out-if-youre-eligible-for-financial-assistance)
- [Find out if you’re eligible for financial assistance](#find-out-if-you-re-eligible-for-financial-assistance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Find out if you’re eligible for financial assistance](#find-out-if-you-re-eligible-for-financial-assistance)
- [Find out if you’re eligible for financial assistance](#find-out-if-you-are-eligible-for-financial-assistance)

(Nitpick) consistency change with what your doing on words like "won't"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - thank you for the suggestion!

Since most governments in the U.S. operate transparently, it’s usually not difficult to discover information about an organization. Anyone can easily find the names, roles, or email addresses of those employed, or details like official records, budgets, or a tax ID. However, it can be difficult to know whether someone approaching us actually is who they say they are, or that they really represent their purported organization.

To prevent someone from using public information to impersonate a government or an official, as well as discourage unauthorized individuals or ineligible organizations from requesting a domain, we verify the identity of new domain requestors using Login.gov. Once your identity has been confirmed, we then conduct a manual review to assess whether you actually work for, or on behalf of, a government.

Login.gov is a secure, government website that adheres to the highest standards in data protection. Most of the data you submit is not stored. You can learn more about the [privacy and security measures](https://login.gov/policy/){.usa-link--external} taken to keep your information safe.

<span id="subdomain"></span>
## Can I request a name like cityname.state.gov (e.g., detroit.mi.gov)?
## Can I request a name like cityname.state.gov (e.g., detroit.mi.gov)? {#subdomain}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Q) Does the slugify library basically add the {#subdomain} functionality where you add the element id at the end like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does! It reads what anchor a user sets in markdown before generating its default slugified anchor and manually set anchors will override the default slugify

Comment on lines +166 to 181
/* markdown-it-anchor header link styling */
h1,
h2,
h3,
h4 {
.header-anchor {
text-decoration-line: none
}

&:hover {
.header-anchor {
text-decoration-line: underline
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and simple!

})
.use(markdownItAnchor,{
permalink: markdownItAnchor.permalink.headerLink({
safariReaderFix: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Would we need we need this fix for any other browsers / what was the issue that we ran into for Safari's Reader mode? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so! I think this is a temporary fix by the markdownItAnchor devs to address a Safari bug so I hopefully don't anticipate any other browser issues, but good point to keep a look at the library for any other accessibility issues they may find in the future

Copy link
Contributor

@therealslimhsiehdy therealslimhsiehdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Giving approval on caveat of adding in Zander's suggested changes (ie the word contraction consistency, etc).

ETA: Looks like there's also a conflict on pages/help/help_faq.md as well

@erinysong erinysong merged commit 89e4d9d into main May 31, 2024
4 checks passed
@erinysong erinysong deleted the es/255-anchor-link-headings branch May 31, 2024 17:56
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

Successfully merging this pull request may close these issues.

Linkify H2-H6 anchors to make sharing URLs more useful
5 participants