Skip to content

MBS-13664: Remember the header search's last selected type - #3922

Open
rahulsjha wants to merge 1 commit into
metabrainz:masterfrom
rahulsjha:MBS-13664
Open

rahulsjha wants to merge 1 commit into
metabrainz:masterfrom
rahulsjha:MBS-13664

Conversation

@rahulsjha

Copy link
Copy Markdown

Problem

MBS-13664. The search box in the header always goes back to "Artist" on the next page, so someone who searches recordings or releases has to pick the type again every time.

Solution

The header search now keeps the type last picked in it, in local storage, as the ticket suggests.

  • common/utility/rememberHeaderSearchType.js: on load, preselects the saved type if it's one of the select's options. On change, it saves the new type. It uses the existing localStorage helper in common/utility/storage.js, which falls back to memory where storage isn't available. A saved type that isn't an option, such as "Documentation" on a server without Google search, is ignored, and the select keeps "Artist".
  • common/headerSearch.js: a new client entry that applies this to #headerid-type. Header.js loads it with {async: true} right after common/MB/Control/Menu, the same way. The script tag comes after the select in the page, so the select is already there when it runs.
  • webpack/client.config.mjs: the new entry.

Without JavaScript nothing changes. The type is saved when it's picked, before searching, so it also carries to the next page if the search isn't submitted.

Before: page 2 is back on Artist; after: page 2 keeps Release group

AI usage

I used Claude (an AI coding assistant) to help write the code and tests, and to run the local checks below. I reviewed the changes and the results.

Testing

  • New tape test tests/utility/rememberHeaderSearchType.js (added to index-web.js): 5 cases, all pass in headless Chromium, built with webpack/tests.config.mjs. It covers a saved type being preselected, a pick being saved, a stale type being ignored, and the latest pick winning.
  • The screenshot above is the header form's markup with the bundle built from common/headerSearch.js. Page 1 picks "Release group", then page 2 loads. Without the script, page 2 shows Artist; with it, Release group.
  • ESLint passes on the changed files, and flow focus-check on them reports 0 errors.
  • I haven't run it on a full MusicBrainz server, so the new manifest('common/headerSearch') in Header.js was checked by reading, not by loading a page from the server.

Test results

The header search went back to "Artist" on every page. A small script,
loaded with the header like the menu's, saves the type picked in it to
local storage and preselects it on the next page. A saved type that is
no longer an option (e.g. "Documentation" without Google search) is
ignored.
Copilot AI balanced review requested due to automatic review settings November 27, 2026 14:23
@welcome

welcome Bot commented Nov 27, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request for MusicBrainz Server, and welcome to our community! 🎉
If you haven’t yet, please check out our contributing guidelines.
Someone will be reviewing your PR soon; just hang in there!
In the meantime, if you’re wondering what to do next, you can have a look at our issue tracker.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@rahulsjha

Copy link
Copy Markdown
Author

@Aerozol could you take a look when you have a moment? This is MBS-13664: the header search keeps the type you last picked (in local storage) instead of going back to Artist on every page, and ignores a saved type the select doesn't offer.

@Aerozol

Aerozol commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

You will have to wait for someone from the developer team to review this :)

@rahulsjha

Copy link
Copy Markdown
Author

@mwiencek Aerozol mentioned this needs someone from the developer team. Could you take a look when you have time? It's MBS-13664: the header search remembers the type you picked last. Small change, with tests.

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.

3 participants