EDITOR: When navigating to an internal link with a heading or block ref, move cursor and viewport to the beginning of the target location

Use case or problem

When mouse clicking or keyboard-navigating to (Opt/Alt-enter) a wikimedia link with a heading reference or a block reference, the cursor in Live Preview Edit goes to the top of the page but the view scrolls to the relevant portion and highlights the block.

The cursor being at the top of the page is unexpected.

Navigating internal links with heading or block references is jarring because

  1. the cursor always goes to the top of the note rather than the context-relevant section
  2. live preview highlights the relevant section with some decoration to visually indicate where you jumped, but that decoration only goes away if you click the mouse. Editing the doc does not clear the highlight.

Heading link

[[Page#Heading]]

Block ref link

[[Page#^b688f2]]

Proposed solution

When mouse clicking or keyboard-navigating to (Opt/Alt-enter) a wikimedia link with a heading reference or a block reference, move the cursor in Live Preview Edit to the context-relevant position.

It would also be helpful if the highlighting on the linked section would disappear when typing starts without having to click the mouse.

Current workaround (optional)

  1. navigate
  2. search through file to find correct location, either visually or search for phrase.

Related feature requests (optional)

5 Likes

Steps to reproduce

Click on a heading-link in Editor mode

Expected result

The linked note should open with the heading on top.

Actual result

The linked headings is in the middle of screen

Environment

  • Operating system: Windows 10 1909 64 bit
  • Obsidian version: 0.9.1

Additional information

In the preview mode all works well.

1 Like

I am not sure I agree with this. Not a bug. Open a feature request.

@WhiteNoise So, why is the behavior different in the two modes?

I am gonna move this back as minor ui bug.

1 Like

NB: Is this a bug report, or is it a discussion of how users want Obsidian to function? See end of post for the latter.

Steps to reproduce

  1. Create a new note (e.g. link-test.md)
  2. Add a header (e.g. # Section)
  3. Add enough text to require scrolling
  4. Add another header of the same level (e.g. # Section 2)
  5. Link to header from a different document (e.g. [[internal-links-test#Section]]
  6. While in Edit mode, click on the link

Expected result

I expect the linked note to open (it does), for the full linked section to be highlighted (it is), and for the section header to be in view. I expect to be navigated to the top of the linked section, as happens when clicking a linked header in Read mode (or when clicking on a header in the Outline core plugin, in Edit or Read mode).

Edit: When in Read mode, clicking a link to open in the same pane works this way. When clicking a command-clicking a link, to open in a new pane, it opens at the bottom of the linked section. I presume this is because I have Edit mode set as my default for new panes.

Actual result

While the internal link does take me to the intended note and does highlight the linked section, it navigates me to the bottom of the linked section. I then have to scroll up to the top of the section to read.

Environment

  • Operating system: macOS Catalina 10.15.7
  • Debug info:

SYSTEM INFO:
Obsidian version: v0.15.6
Installer version: v0.14.6
Operating system: Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64 19.6.0
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: light
Community theme: Minimal
Snippets enabled: 1
Safe mode: off
Plugins installed: 8
Plugins enabled: 7
1: Advanced Tables
2: Hider
3: Minimal Theme Settings
4: Obsidian TODO | Text-based GTD
5: Todo.txt support
6: Periodic Notes
7: Rollover Daily Todos

RECOMMENDATIONS:
Custom theme: for cosmetic issues, please first try updating your theme to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.


Now, is this a bug or a feature?

I can see a case for why this could be intended behavior. In Read mode, you’re reading so it makes sense to start at the top; in Edit mode, you are writing, and writing happens at the end of a section. It could, then, make sense to navigate to the bottom of a section so you can immediately start writing.

However, in my experience, when I am following a link while in Edit mode, my goal is to read a previous note or copy a previous note, to add to my writing elsewhere. I am not following the link to write in the linked document.

But maybe I am alone in this.

If this is not the intended behavior, here is a bug report! If it is intended, perhaps we could discuss whether this is how we want Obsidian internal links to work.

2 Likes

You are not alone. i wanted it to open to the top as well. I guess feature request. Cheers.

Yes, I also find this annoying.

A possible compromise feature: create shortcuts to go to the top or bottom of current end heading. Like a fancy home/end key. Like home-1 to go to top of current H1, home-2 to go to top of current H2, etc.

Use case or problem

Normally when you follow a URL fragment (for example, in a web browser) the linked-to element of the page is loaded into view — usually at the top, or the bottom (awkward but at least it’s there), or maybe in the middle.

When you follow one in Obsidian — a link to a heading — the entire section under the heading is highlighted and the end of the section is loaded into view, often putting the linked-to heading off-screen. The highlight is nice, but this is surprising and inconvenient. When I follow a link to a heading, I expect to see the heading.

Proposed solution

Load the top of the section, not the bottom. Ideally (I think), place it in the middle of the screen to avoid the confusion that sometimes results when the looked-for item is at the very top or bottom edge of the screen.

Obsidian already behaves in the requested way in Reading Mode (as I learned from Highlight entire section when opening links to headings in reading/preview mode as opposed to only highlighting the heading).

Current workaround (optional)

I’m not working around it. I could link to the section before the one I want (if any), but I don’t because it’s an ugly, misleading hack.

Related feature requests (optional)

Original version of this request as a bug report:

Conceptually related Mobile bug report (I know the code bases differ):

Similar behavior as the Mobile bug, restricted to certain circumstances:

Cursor goes to one place, view to another:

This sentence is so people who write “header” instead of “heading” can find this post.

9 Likes

This is the most annoying behavior in Obsidian, especially for long sections.
Workaround is to enter Preview mode before following a link to a section. The desired behavior (landing on the heading itself / highlighting only the heading) is implemented in Preview mode, but not in Editing.

2 Likes

will be implemented/fixed in v0.16.

5 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.