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

Reimplement timeout countdown as custom element #6023

Merged
merged 10 commits into from
Mar 15, 2022
Merged

Conversation

aduth
Copy link
Member

@aduth aduth commented Mar 2, 2022

Why:

  • Reduce size and scope of hot-path application pack
  • Avoid relying on window globals (LoginGov.countdownTimer), since they rely on fragile dependency order
  • Improve testability of element behavior in isolation
  • Allow reuse for common countdown behavior

There is not expected to be any functional behavior differences with these revisions.

app/components/countdown_component.ts Outdated Show resolved Hide resolved
app/views/session_timeout/_warning.html.erb Outdated Show resolved Hide resolved
@aduth aduth force-pushed the aduth-countdown-component branch from efb324e to 3667619 Compare March 14, 2022 15:26
@aduth
Copy link
Member Author

aduth commented Mar 14, 2022

Performance impact on application pack:

  Before After Diff%
raw 10.00kb 8.97kb -10.3%
gzip 3.49kb 3.14kb -10.03%
brotli 3.03kb 2.75kb -9.24%

Overall pretty small in terms of absolute numbers, but architecturally feels better to split out this way to limit scope of the pack. That, plus other benefits listed in original comment still apply.

Copy link
Contributor

@mitchellhenke mitchellhenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼 👏🏼

aduth added 10 commits March 15, 2022 11:21
**Why**:

- Reduce size and scope of hot-path application pack
- Avoid relying on window globals (LoginGov.countdownTimer), since they rely on fragile dependency order
- Improve testability of element behavior in isolation
- Allow reuse for common countdown behavior

changelog: Internal, Optimziation, Reduce size of common JavaScript file
- Simplify tests to avoid accounting for newline
- Because it's single, simple tag

See: #6023 (comment)
**Why**: Avoid errors in runtime
Seemingly more compatible with element lifecycle, where dataset can be undefined prior to element being connected. For example, when `define`-ing the custom element, the attributeChangedCallback is triggered, but the element isn't yet mounted.
Example snippets often use getter syntax, since it's better supported in older browsers. But since we transpile, and since reasonably new browsers support static variables, we can update to simplify.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static
**Why**: To restore previous behavior of screen reader atomic announcement including time remaining.
@aduth aduth force-pushed the aduth-countdown-component branch from 2029c03 to 0c4c4e9 Compare March 15, 2022 17:44
@aduth aduth merged commit ef0457d into main Mar 15, 2022
@aduth aduth deleted the aduth-countdown-component branch March 15, 2022 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants