Skip to content

Skip turbo:before-cache reset for editors inside turbo-permanent elements#977

Merged
rosa merged 1 commit intomainfrom
skip-reset-for-turbo-permanent-editors
Apr 17, 2026
Merged

Skip turbo:before-cache reset for editors inside turbo-permanent elements#977
rosa merged 1 commit intomainfrom
skip-reset-for-turbo-permanent-editors

Conversation

@rosa
Copy link
Copy Markdown
Member

@rosa rosa commented Apr 15, 2026

Summary

  • Lexxy editors inside [data-turbo-permanent] containers are no longer reset during turbo:before-cache
  • These editors are excluded from Turbo's page snapshot, so resetting them is unnecessary and destructive — their connectedCallback never fires again to restore the editor

Problem

When a Turbo page visit occurs, Lexxy's turbo:before-cache handler 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), so connectedCallback never 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

  • Open a page with a Lexxy editor inside a [data-turbo-permanent] element (e.g. sidebar ping in Basecamp)
  • Trigger a full Turbo page visit (e.g. enter card edit mode via title click, then click "Never Mind")
  • Verify the editor remains functional after navigation
  • Verify editors outside [data-turbo-permanent] still reset correctly on turbo:before-cache

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings April 15, 2026 16:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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() on turbo:before-cache when the editor is within a [data-turbo-permanent] ancestor.
  • Preserve existing turbo:before-cache reset behavior for non-permanent editors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/elements/editor.js
Comment on lines 394 to +397
#handleTurboBeforeCache = (event) => {
this.#reset()
if (!this.closest("[data-turbo-permanent]")) {
this.#reset()
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@rosa rosa merged commit fb215eb into main Apr 17, 2026
16 checks passed
@rosa rosa deleted the skip-reset-for-turbo-permanent-editors branch April 17, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants