Skip turbo:before-cache reset for editors inside turbo-permanent elements#977
Skip turbo:before-cache reset for editors inside turbo-permanent elements#977
Conversation
…ents Lexxy editors register a turbo:before-cache listener that calls #reset() to clean up before Turbo snapshots the page. However, editors inside [data-turbo-permanent] elements are excluded from the snapshot — they're preserved as-is across navigations. Resetting these editors destroys their contenteditable div, and since the element is never disconnected/reconnected, connectedCallback never fires to restore it. This caused the sidebar ping editor in Basecamp to become permanently locked out after entering and exiting card edit mode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Lexxy’s Turbo integration so editors inside data-turbo-permanent containers are not reset during turbo:before-cache, preventing permanent editors from becoming unusable after Turbo navigations.
Changes:
- Skip
#reset()onturbo:before-cachewhen the editor is within a[data-turbo-permanent]ancestor. - Preserve existing
turbo:before-cachereset behavior for non-permanent editors.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #handleTurboBeforeCache = (event) => { | ||
| this.#reset() | ||
| if (!this.closest("[data-turbo-permanent]")) { | ||
| this.#reset() | ||
| } |
There was a problem hiding this comment.
This behavior change (skipping #reset during turbo:before-cache when the editor is within a [data-turbo-permanent] ancestor) is not covered by automated tests. Please add a Playwright browser test that (1) mounts an editor inside a data-turbo-permanent container, dispatches turbo:before-cache, and asserts the .lexxy-editor__content remains present/usable, and (2) verifies a non-permanent editor still resets on the same event.
Summary
[data-turbo-permanent]containers are no longer reset duringturbo:before-cacheconnectedCallbacknever fires again to restore the editorProblem
When a Turbo page visit occurs, Lexxy's
turbo:before-cachehandler calls#reset()on every editor, removing the internal contenteditable div. For editors inside[data-turbo-permanent]elements, the element stays in the DOM (never disconnected/reconnected), soconnectedCallbacknever fires to recreate the editor. This permanently locks the user out of that editor until a full page refresh.In Basecamp, this manifests as the sidebar ping text input disappearing after entering and exiting card edit mode.
Test plan
[data-turbo-permanent]element (e.g. sidebar ping in Basecamp)[data-turbo-permanent]still reset correctly onturbo:before-cache🤖 Generated with Claude Code