4site-interactive-studios / engrid

The Unlicense
10 stars 4 forks source link

New feature: Thank you page conditional content #297

Closed MichaelT372 closed 6 months ago

MichaelT372 commented 6 months ago

Task: https://app.productive.io/2650-4site-interactive-studios-inc/tasks/6518937

This feature implements the request for: add the "Hide any element based on the selected value of a checkbox or radio select field" class type to work on thank you pages

It extends ShowHideRadioCheckoxes to save the state of each set of controls initialised by that class into sessionStorage. Then, a new class ThankYouPageConditionalContent handles applying that state on a thank you page.

Because of the fragile nature of handling input states this way, there are some defensive practises implemented in the handling such as:

This means this code will work for its intended purpose - displaying some conditional content on a thank you page - but would need further considerations if it were to be extended to generally allow conditional content to persist across chained pages.

Test page: https://protect.worldwildlife.org/page/66734/donate/1

The test page is set up to load a build of WWF's theme using this engird-scripts branch and has a block on the thank you page for various pieces of conditional content. This PR is only concerned with the final section of that block under the header of "Hide any element based on the selected value of a checkbox or radio select field".

fernanDOTdo commented 6 months ago

Hey, @MichaelT372 !

I noticed the created typescript file has no comments. Was the documentation updated to explain this feature?

Thank you!