Skip to content

fix(footnote): position the preview popup from the current footnote's height - #1495

Merged
xiaolai merged 2 commits into
mainfrom
fix/issue-1494-footnote-popup-position
Oct 4, 2026
Merged

xiaolai merged 2 commits into
mainfrom
fix/issue-1494-footnote-popup-position

Conversation

@xiaolai

@xiaolai xiaolai commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

The footnote preview popup sits above its reference, so its position depends on its own height. The WYSIWYG popup measured itself before resizing its textarea for the footnote being shown, so it reused the previous footnote's height. Hovering footnote ① and then ② put ② at ①'s offset; hovering ② again was correct, because the leftover height was by then its own. That matches every step in #1494.

Source mode had a worse version of the same bug: the base view never re-showed a popup that was already open, so hovering straight from one footnote to another kept the old text at the old place. It also always positioned as if 100px tall.

Policy Gates (Required)

  • This PR is single-focus (one issue, one problem, one objective).
  • This PR includes 100% test coverage for changed behavior and changed code paths.
  • If this is a bug fix, the linked issue contains detailed reproduction context.

Linked Issue

Type of Change

  • Bug fix
  • Feature
  • Docs
  • Refactor
  • Test-only
  • Other

What Changed

  • WYSIWYG (FootnotePopupView): size the textarea before measuring and positioning; re-position on input as the popup grows.
  • Source footnote (SourceFootnotePopupView): override SourcePopupView.shouldReshow (now on main) to re-show when the hovered footnote changes; position from the rendered height after the content is set; re-position on input.
  • Both modes: re-anchor when the hover moves to another reference of the same footnote (same label, different referencePos; only openPopup writes that field, so this cannot fire spuriously).
  • Docs: website/guide/popups.md (all locales) now lists the Source-mode trigger for footnote popups.

Known limit: in Source mode, moving from a footnote's definition to its reference doesn't re-anchor, because both carry the same label and referencePos. Re-showing on every anchor change would instead reset unsaved edits when the same footnote is clicked again.

Validation

  • I ran pnpm check:all locally.
  • I added or updated tests to fully cover behavior changes.
  • I manually verified critical flows.

Two new *.position.test.ts files (11 tests) were written first and seen failing, including the reporter's exact sequence and the Source-mode stale-text case. jsdom has no layout, so the tests simulate one in which the textarea's scrollHeight follows its text and the container's height follows the textarea.

Not verified in the running app. Manual check: hover a long footnote, then move straight to a short one — the gap above the reference should stay constant, in both WYSIWYG and Source mode.

UI Evidence (if applicable)

None yet — see the manual check above.

PR Checklist

  • The PR avoids unrelated refactors or cleanup.
  • The issue context is clear (linked issue or explanation above).
  • Docs/changelog were updated if behavior or usage changed.
  • I am ready to address review feedback.

@xiaolai

xiaolai commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

The red frontend check comes only from the fe-static security-audit step: a new, unfixed braces advisory (GHSA-vfj7-8cjw-p6xm) that fails every PR, main included. Unblocked by #1496; I'll update this branch from main once #1496 merges.

… height

The footnote preview sits above its reference, so its offset depends on
its own height. The WYSIWYG popup measured itself before resizing the
textarea for the new footnote, so it reused the previous footnote's
height: hovering one footnote and then another placed the second at the
first one's offset until it was hovered again.

- WYSIWYG: size the textarea before measuring; re-position on input.
- Source mode: hovering straight to another footnote kept the old text
  at the old place, and the popup always positioned as if 100px tall.
  The source footnote popup now uses SourcePopupView's shouldReshow
  hook to re-show on a new footnote, and positions from its rendered
  height after the content is set.
- Both modes re-anchor when the hover moves to another reference of the
  same footnote.

Closes #1494
The guide listed only the WYSIWYG trigger. In Source mode the popup
opens on hover or click over a footnote reference or definition.
Updated in every locale.
@xiaolai
xiaolai force-pushed the fix/issue-1494-footnote-popup-position branch from 230dbb4 to e8e1bf6 Compare October 4, 2026 01:36
@xiaolai
xiaolai merged commit 1b02f03 into main Oct 4, 2026
17 checks passed
@xiaolai
xiaolai deleted the fix/issue-1494-footnote-popup-position branch October 4, 2026 02:12
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] 引用预览区的相对高度计算有延迟和错误缓存

1 participant