Repository navigation
Conversation
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.
|
Thanks for opening your first pull request for MusicBrainz Server, and welcome to our community! 🎉 |
Author
Contributor
|
You will have to wait for someone from the developer team to review this :) |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Onchange, it saves the new type. It uses the existinglocalStoragehelper incommon/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.jsloads it with{async: true}right aftercommon/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.
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
tests/utility/rememberHeaderSearchType.js(added toindex-web.js): 5 cases, all pass in headless Chromium, built withwebpack/tests.config.mjs. It covers a saved type being preselected, a pick being saved, a stale type being ignored, and the latest pick winning.common/headerSearch.js. Page 1 picks "Release group", then page 2 loads. Without the script, page 2 shows Artist; with it, Release group.flow focus-checkon them reports 0 errors.manifest('common/headerSearch')inHeader.jswas checked by reading, not by loading a page from the server.