Closing the search bar disruptively scrolls the page to a highlighted search result

Steps to reproduce

  • Create a note with a couple pages worth of text
  • Search within the note for some text
  • Scroll away from the highlighted search result; begin editing the note somewhere else
  • Close the search bar, either by clicking the X, or by pressing the [Esc] key
  • Notice that you’ve been forcibly scrolled back to the search result, and your cursor has moved there as well.

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

Yes

Expected result

I’m closing the search bar because I don’t need it any more, or it’s in the way, so I expect it to disappear without affecting my scroll position or my cursor.

Actual result

I am forcibly scrolled back to a search result, and my cursor is moved there as well.

Environment

SYSTEM INFO:
Obsidian version: v1.4.13
Installer version: v1.4.5
Operating system: Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020 22.6.0
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

I agree with you but they say it’s on purpose.

I don’t believe that – there’s just no sane rationale for wanting that behavior. My guess is that when you close it, it briefly gets the focus, and when it has the focus, it highlights and scrolls to the search result. The second half of that is intended I’m sure, but the fact that it also happens when you’re just closing the search bar is IMO very unlikely to be intended. Maybe highlighting and scrolling should only happen when the text input is focused, rather than the whole search bar element?

I agree.

This would be much better.

Hopefully they will reconsider.

You know I don’t recall at all that br and my response. I’ll check it again.

1 Like

yes, this is clearly a bug. That response was likely for another thread and I messed up with all tabs open.

2 Likes

Np, thanks for getting it sorted out. This will be a nice improvement.