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

Refactored highlight behavior: Preserved original content structure + handle "BODY" selector #38

Merged
merged 16 commits into from
Aug 25, 2023

Conversation

jespernpedersen
Copy link
Contributor

@jespernpedersen jespernpedersen commented Aug 23, 2023

Notice!

This PR is not breaking any tests. Our WPCS test pipeline is currently broken, as we also tested this on the master branch and it was also just today started to fail on that. I have reached out to Frederik from infra to see if it's an issue with GA runners on their end, but this PR can still be reviewed regardless of the broken test pipeline.

Problem

  1. For some highlights, we saw that the html structure had been permanently altered (a page fresh is needed to undo the structure changes) even after navigating away from the individual highlight. It would remove text node items such as <em> <a> etc.

  2. After adding new highlightable issues, we discovered that some of them targeted "BODY" tag, in which caused an anomaly with highlighting and caused the page to refresh.

Before (Problem) - Video:
https://github.com/Siteimprove/CMS-plugin-Wordpress/assets/25395486/5f13e37e-a653-4775-b8d9-b866d0560252

Solution

  1. We store the original content of all currently highlighted elements before making any changes.
  2. Restore the original content by replacing the highlighted span with the stored content.
  3. Apply new highlights
  4. We have a si-full-highlight that can handle the case of "BODY" tag, by highlighting the entire page

This ensures that previous highlights are removed and the structure remains intact before applying new highlights and that we can handle the scenario of full page highlights.

After (Solution) - Video:
https://github.com/Siteimprove/CMS-plugin-Wordpress/assets/25395486/82e9a4bb-5b5b-4599-b987-3f067d56a953

Full Page Highlight - Video:
https://github.com/Siteimprove/CMS-plugin-Wordpress/assets/25395486/4aa1e97d-225e-4d39-a205-b6e9f615d3ec

@jespernpedersen jespernpedersen changed the title Refactored highlight behavior: preserved original content structure Refactored highlight behavior: Preserved original content structure Aug 23, 2023
@jespernpedersen jespernpedersen changed the title Refactored highlight behavior: Preserved original content structure Refactored highlight behavior: Preserved original content structure + handle "BODY" selector Aug 23, 2023
@jespernpedersen jespernpedersen marked this pull request as ready for review August 23, 2023 09:47
@jespernpedersen jespernpedersen marked this pull request as draft August 23, 2023 12:14
@jespernpedersen jespernpedersen marked this pull request as ready for review August 23, 2023 13:33
@jespernpedersen jespernpedersen merged commit 0e4b918 into master Aug 25, 2023
1 check failed
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.

3 participants