[Search plugin] Search result navigation doesn't work correctly for footnotes in Reading View

Steps to reproduce

  • Search for the word that’s present in the footnotes.
  • Click the related search result item.

Did you follow the troubleshooting guide? [Y/N]

Yes

Expected result

Focusing on footnotes works correctly for the appropriate search result item.

Actual result

When navigating the search result item, the appropriate footnote isn’t scrolled and highlighted correctly in Reading View mode.
NOTE: It works well for the last footnote.

Environment

SYSTEM INFO:
Obsidian version: v1.8.3
Installer version: v1.7.7
Operating system: Darwin Kernel Version 24.2.0: Fri Dec 6 18:41:43 PST 2024; root:xnu-11215.61.5~2/RELEASE_X86_64 24.2.0
Login status: not logged in
Language: en
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

[Tech details]

The last footnote is properly selected and the appropriate CSS class is added to the right DOM element.



Any other footnote is not properly selected and the appropriate CSS class is added to the wrong DOM element.

I’d like to provide a valid use case for showing how the fix could reduce time in finding necessary information.
Suppose you have text in your note with terms which you’d like to define using footprints for reference. Let’s say you have them around 50. Now you might want to search for some term in your footprint to quickly see what it means and you might want to see in which context it’s used as the term might have different definitions. So, navigating from the search result to a proper footnote item in View mode allows you navigate back and forth between the context and the definition easily.