Skip to content

Tear down AutoClearPassword directive on page navigation#24808

Open
sgiehl wants to merge 6 commits into
6.x-devfrom
dev-19322
Open

Tear down AutoClearPassword directive on page navigation#24808
sgiehl wants to merge 6 commits into
6.x-devfrom
dev-19322

Conversation

@sgiehl

@sgiehl sgiehl commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

The AutoClearPassword directive registered its listeners, timers and an
element-level cleanup handle in mounted, but only tore them down in the Vue
unmounted hook. unmounted does not run on a full page navigation, so the
watcher (and the value it tracked) was left in place when leaving the page.

This adds a pagehide teardown path so the directive cleans up on navigation as
well as on component unmount:

  • clears the pending timeout and the polling interval
  • removes the input/change listeners and the pagehide listener
  • drops the tracked value and the onUmounted handle on the element
  • empties the field when leaving the page

Both entry points share a single teardown() helper so unmount and navigation
behave consistently. On a back/forward-cache transition (pagehide with
persisted) the value is dropped but the watcher stays armed, so a restored
page keeps working. Setup is also guarded so the same input is never armed
twice.

Regression tests are added in AutoClearPassword.spec.ts.

Review

  • Field still auto-clears after the configured delay
  • Nothing is left registered after navigating away

Built bundles (CoreHome.umd.js, CoreHome.umd.min.js) are included.

Checklist

  • [βœ”] I have understood, reviewed, and tested all AI outputs before use
  • [βœ”] All AI instructions respect security, IP, and privacy rules

@sgiehl sgiehl added this to the 6.0.0 milestone Jul 12, 2026
sgiehl added 2 commits July 21, 2026 16:39
The directive only cleaned up on Vue unmount, which does not run on a
full page navigation. Also tear down on pagehide so timers, listeners
and the field value are cleared when leaving the page.
Keep the watcher armed across back/forward-cache transitions (pagehide
with persisted=true) instead of disarming it, guard against arming the
same input twice, and add Jest coverage for the teardown paths.
github-actions[bot]

This comment was marked as outdated.

The directive only reset the DOM value, but its Vue consumers bind the
field through v-model. On a bfcache restore (and on the inactivity
timeout) the reactive model still held the old value, so the next render
wrote the password back into the input. Dispatch a change event on clear
so the password Field syncs its model to empty as well.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

πŸ€– Codex Review: πŸ’¬ Low / Polish

Summary

This PR correctly adds shared teardown for normal navigation, bfcache transitions, and Vue unmounting, with focused regression coverage. The implementation appears merge-ready; the only requested cleanup is ensuring each test tears down its directive so intervals and global listeners do not leak between cases.

Findings Overview

Severity Count
🚫 Blocking 0
⚠️ Medium 0
πŸ’¬ Low / Polish 1

πŸ“ Posted 1 inline finding.

Diagnostics

Detailed review diagnostics are available in the codex-review-output workflow artifact.

sgiehl added 2 commits July 22, 2026 14:38
The specs mount the directive manually, so clearing the DOM node did not
fire the unmounted hook, leaving each test's polling interval and global
pagehide listener active for later cases. Explicitly tear each input down
in afterEach to keep the suite isolated.
@sgiehl
sgiehl marked this pull request as ready for review July 23, 2026 15:40
@sgiehl
sgiehl enabled auto-merge (squash) July 23, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant