NUKnightLab / NUKnightLab/TimelineJS3

Timeline component is missing the teardown flow

Open
#742 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3.2k
Forks
645
PR merge metrics
No merged PRs in 30d

Description

We develop a SPA web app and there appeared a need to dynamically replace the theme of the Timeline.

If we pass the different a theme prop, e.g. "contrast", to the options, the component will load the "contrast" theme CSS file. But then we'll not be able to get back to the normal theme, because the "contrast" stylesheet is stuck in the DOM. It would be much better if there was an ability to delete all the previously downloaded styles from the DOM.

A similar thing happens with the different script tags that are loaded as part of the Media, e.g. Imgur. When the TL is mounted, it loads the Imgur script and appends it to the DOM. If I try to render the same Timeline again, the Imgur script will be added the second time to the DOM.

https://user-images.githubusercontent.com/68850090/173536604-2c88c34d-0f62-4bdd-9706-f5c81c598698.mp4

Therefore, it would be great to have some public remove method on the Timeline class that will remove all the downloaded assets from the DOM when is about to get unmounted. This removal can still be manual and the teardown responsibility can lay on the library consumers. I think it'll give more control over how the TL is rendered.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Timeline class and trace how theme stylesheets and Media scripts are appended during mounting or rendering. Done means a public remove method can remove previously downloaded assets from the DOM, including theme CSS and duplicate Imgur scripts, without leaving stale assets behind.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.