CHAL-53 #done - Implement election reminders page #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Overview
This PR implements the Election Reminders page by executing a script provided by Rock the Vote. To style the form itself, I provided a stylesheet to RTV via the partner dashboard. I was not able to preview the election reminders page via the dashboard (the only form you can preview is the registration form), so I performed tests locally by copying the body element rendered by the RTV script, pasting it into an html file and styling that. I also experimented with editing the styles for different elements within the form live in the browser. These approaches had their limitations though, and I have had to submit the stylesheet for approval several times now. Additionally, getting the labels to float up (and remain floated) once the user interacted with a field was tricky. The approach that I took was to apply an animation to all the labels with an iteration count of 1 and a fill mode of
forwards
and set theanimation-play-state
property to paused. I then used the:focus
pseudo-class to setanimation-play-state
torunning
.Despite my best efforts, there are a few remaining issues with the styles. These include:
I did come up with and test solutions for these problems. These issues will be resolved once RTV has approved my latest stylesheet submission, so the PR itself is ok to merge regardless. It's the weekend now, so I expect they should approve that Monday or Tuesday.
Another issue is that the RTV script uses the
document.write()
function to create its content. External scripts that use this function in a React app must havedocument.open()
explictly called before they execute. To get around this issue and render the form, I rendered it in an IFrame and passing in the code that renders the form via thesrcdoc
property.Because the RTV script renders the form it creates in a cross-origin IFrame (this is not the IFrame I created, but rather an IFrame inside my IFrame), our application can't access any information about what is going on inside the IFrame. The only way that I can determine if the form has been successfully submitted is actually the
scrollHeight
of thecontentWindow.document.body
of the outer IFrame--the completed page is much smaller in height than the page that displays the form. I was able to use aResizeObserver
to watch for this change, and when the form has been successfully submitted, the user's record is updated and a badge is awarded.All told, I had to use a lot of little tricks to get the election reminders page to do what it's supposed to--display the RTV form with styles that match the rest of the app and award the user a badge when the form is completed--but the end result is good and reliable. Hopefully in the future, RTV adds an API endpoint like they have for registrations so that this can all be done with Fully Formed instead.
Here is a screencast for reference:
https://www.awesomescreenshot.com/video/31780627?key=ec7e86b4205f8b2bc9ee7f925bb1f1b2
Test Plan
100% of the code is covered by unit tests.
Follow ups
We will need to verify the styles once more once approved by RTV. In the future, it would be nice if we could accomplish this more simply, such as with an API and Fully Formed.