Skip to content

autodoc: Use the search input's value on load #24467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mdsib
Copy link

@mdsib mdsib commented Jul 15, 2025

After the sources tarball is loaded, check the search input for a value. If present, this means the user typed something into it during load - we should use that value for the initial search state instead of always respecting what the hash's search value is.

Updates for clarity:

  • history.state: {} => "keepScrollPosition" :: We're using state as a flag, but as it was an empty object, wasn't clear to me what it was being used for. Hopefully this state's value will be self-documenting and provide more clarity for future contributors.

  • onHashChange => handleNavigation :: onHashChange implies there's a onhashchange event that's being handled, which isn't the case.

Future considerations:

  • since no event handlers are registered until the tarball loads, we don't get s or ? shortcuts. it would be straightforward to shuffle things around to get these working, but I figured I'd keep this PR short.
  • calling handleNavigation(null ... ) after tarball load forces a scroll to the top - I kept this behavior unchanged, but it does result in users losing their place via a refresh.

Fixes #21458

After the wasm loads, check the search input for a value. If present,
this means the user typed something into it during load - we should
use that value for the initial search state instead of always
respecting what the hash's search value is.

Updates for clarity:

- history.state: {} => "keepScrollPosition"
  We're using state as a flag, but as it was an empty object, wasn't
  clear to me what it was being used for. Hopefully this state's value
  will be self-documenting and provide more clarity for future
  contributors.

- onHashChange => handleNavigation
  onHashChange implies there's a onhashchange event that's being
  handled, which isn't the case.
@mdsib mdsib marked this pull request as draft July 16, 2025 20:03
@mdsib mdsib marked this pull request as ready for review July 16, 2025 22:03
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.

autodoc: don't delete search text upon loading
1 participant