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

DS-576 | @ericbakenhus | Remove WYSIWYG empty links #408

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ericbakenhus
Copy link
Contributor

NOT READY FOR REVIEW

Summary

  • Do not render any empty links entered in a rich text field

Review By (Date)

  • End of sprint

Criticality

  • Low

Review Tasks

Setup tasks and/or behavior to test

  1. Check out this branch
  2. Navigate to...
  3. Verify...

Associated Issues and/or People

  • DS-576

@@ -12,6 +12,7 @@ function createMarkup(storyblokHTML) {
allowedTags: false, // This allows extra HTML tags to be rendered, e.g., H2, img
allowedAttributes: false, // This allows custom class names
allowVulnerableTags: true, // https://github.com/apostrophecms/sanitize-html/blob/main/CHANGELOG.md#1250
exclusiveFilter: (frame) => frame.tag === 'a' && !frame.text.trim(), // Remove empty links
Copy link
Contributor Author

@ericbakenhus ericbakenhus Mar 18, 2024

Choose a reason for hiding this comment

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

Removes empty links. The sanitize-html docs use removing empty links as their exclusiveFilter example: https://www.npmjs.com/package/sanitize-html#filters 😆

Copy link
Member

Choose a reason for hiding this comment

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

ah, that's niiice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sherakama Unlike the related Alumni site fix, this will also remove links that have child elements (e.g. <br>) as long as there's no eventual text ancestors. That could cause some unexpected layout shifting.

I think I'm going to close this PR, manually handle the handful of WYSIWYG issues to get rid of the a11y issue, then handle this in the site rebuild instead...

Copy link
Member

Choose a reason for hiding this comment

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

That sounds like a reasonable pivot to me.

You can put this into draft to keep it around for a bit if you'd like.

@ericbakenhus ericbakenhus marked this pull request as draft April 4, 2024 16:26
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.

2 participants