Skip to content

Fix emoji panel remaining visible after SPA navigation - #266

Merged
ruibaby merged 5 commits into
mainfrom
fix/spa-emoji-panel-residue
Nov 7, 2026
Merged

ruibaby merged 5 commits into
mainfrom
fix/spa-emoji-panel-residue

Conversation

@ruibaby

@ruibaby ruibaby commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Problem

On sites that navigate without a full reload (Swup, Turbo, PJAX), the comment
widget's emoji panel is a shared element appended to document.body, while its
visibility relied on a <style> element injected into document.head.

SwupHeadPlugin removes runtime-injected head tags that are not part of the
incoming document before replacing the page content. After the first in-site
navigation the panel therefore lost its display: none rule and reappeared at
its last position. It could not be closed afterwards because the new page's
buttons were in the closed state and the previous button had been removed.

Fix

  • Toggle the panel visibility with an inline display style, so hiding no
    longer depends on the injected stylesheet.
  • Restore the shared stylesheet and reattach the panel wrapper when they are
    missing or detached.
  • Recreate the emoji picker when its wrapper was detached; emoji-mart marks
    disconnected pickers as unusable.
  • Revalidate the button's connection and active state after the lazy picker
    import, so navigation during the first load cannot reopen the panel.
  • Reset a button's expanded state when it is disconnected.
  • Create only one picker when several buttons open the panel concurrently.

Reproduction

  1. Open a post and click the emoji button in the comment editor.
  2. Close the panel.
  3. Navigate to another page without a full reload.

Before the fix, the panel reappeared at its last position and could not be
closed. After the fix it stays hidden, and navigating while the panel is open
also closes it.

Validation

  • pnpm -C packages/comment-widget test — 38 test files / 190 tests pass.
  • pnpm exec tsc --noEmit -p packages/comment-widget/tsconfig.json — pass.
  • biome check on the changed files — pass.

Added browser regression tests covering style removal, pages without the
comment widget, navigation while open, whole-body replacement, an interrupted
first load, reattached buttons, and concurrent first opens.

Fixes #264

plugin-comment-widget-3.5.1-build.266.jar.zip

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T14:42:44.762499Z fed1e32 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Browser test files that share a session also share IndexedDB, so an upload ticket left by one file could make comment-form submission recover a stale pending submission and never post in another file. Delete the draft database in afterEach together with localStorage.
@ruibaby
ruibaby merged commit af06acc into main Nov 7, 2026
2 checks passed
@ruibaby
ruibaby deleted the fix/spa-emoji-panel-residue branch November 7, 2026 14:46
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.

[BUG] 表情面板在 SPA(Swup)主题换页后残留且无法关闭

1 participant