Skip to content

Conversation

@cotti
Copy link
Contributor

@cotti cotti commented Jan 9, 2026

Fixes #2440

Summary

This pull request adds a cleanup routine to ensure that certain web components and portal containers are properly reset before htmx saves the page state to its history cache in localStorage. This prevents issues with stale or orphaned DOM elements during client-side navigation.

Frontend cleanup improvements:

  • Added an event listener for htmx:beforeHistorySave in main.ts to clear the inner HTML of applies-to-popover, version-dropdown, and search-or-ask-ai web components before htmx caches the page.
  • Removed orphaned EUI portal containers (elements with data-euiportal="true") before htmx history caching to prevent DOM clutter during navigation.

@cotti cotti self-assigned this Jan 9, 2026
@cotti cotti added the fix label Jan 9, 2026
@cotti cotti requested a review from a team as a code owner January 9, 2026 17:18
@cotti cotti requested a review from Mpdreamz January 9, 2026 17:18
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

LGTM for a hot patch, we should tackle this more generically near term.

Either through hx-history="false"

htmx.config.historyCacheSize = 0;

This caching behaviour will go away with htmx 4.0 anyhow

https://htmx.org/essays/the-fetchening/#htmx-4-the-fetch-ening

@cotti
Copy link
Contributor Author

cotti commented Jan 9, 2026

LGTM for a hot patch, we should tackle this more generically near term.

Either through hx-history="false"

htmx.config.historyCacheSize = 0;

This caching behaviour will go away with htmx 4.0 anyhow

https://htmx.org/essays/the-fetchening/#htmx-4-the-fetch-ening

Ah, hx-history-elt would probably do it on a per-element basis.

@cotti cotti merged commit 356ad2e into main Jan 9, 2026
30 checks passed
@cotti cotti deleted the fix/badge_history branch January 9, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Badges leaking on page upon using previous/next browser buttons

3 participants