pressbooks / pressbooks-book

McLuhan is the default book theme for Pressbooks.
https://pressbooks.org
GNU General Public License v3.0
20 stars 16 forks source link

fix: CTA dismiss button #1123

Closed fdalcin closed 1 year ago

fdalcin commented 1 year ago

Fixes pressbooks/pressbooks-book#1125

This PR aims to fix an issue when trying to add an event listener to an element that does not exist anymore. The issue happens when updating the network settings to not display the default CTA banner.

image

When visiting a book page, the banner is not displayed as expected but the page still tries to add an event listener to the CTA button causing the code to break

image

How to test

  1. Disable the CTA banner on the network settings
  2. Visit a book page notice the error message
  3. Switch to this branch and make sure the error message is not there when you visit the book again
  4. Enable the CTA banner again and make sure the banner is dismissible
codecov[bot] commented 1 year ago

Codecov Report

Merging #1123 (d367c65) into dev (6ef0550) will not change coverage. The diff coverage is n/a.

Additional details and impacted files [![Impacted file tree graph](https://codecov.io/gh/pressbooks/pressbooks-book/pull/1123/graphs/tree.svg?width=650&height=150&src=pr&token=OGTBGoKr4m&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks)](https://codecov.io/gh/pressbooks/pressbooks-book/pull/1123?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks) ```diff @@ Coverage Diff @@ ## dev pressbooks/pressbooks#1123 +/- ## ======================================= Coverage 46.68% 46.68% ======================================= Files 3 3 Lines 452 452 ======================================= Hits 211 211 Misses 241 241 ``` ------ [Continue to review full report at Codecov](https://codecov.io/gh/pressbooks/pressbooks-book/pull/1123?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/pressbooks/pressbooks-book/pull/1123?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks). Last update [6ef0550...d367c65](https://codecov.io/gh/pressbooks/pressbooks-book/pull/1123?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pressbooks).