This repository was archived by the owner on Sep 30, 2024. It is now read-only.
fix(svelte): Prefill search home page query input with (default) context filter#63740
Merged
Merged
Conversation
Currently we don't show the global context filter on the search home page or the search results page (global context is the default context). This commit does two things: - It prefills the search input on the search homepage with the user's default context (like the React app) - It the logic that pre-processed the search query and removed the context filter if it was global. In other words we simplify the query logic by showing/submitting the search query as is. Noteably this doesn't affect how the search input works on repo pages.
744e473 to
591e10c
Compare
fkling
commented
Jul 9, 2024
| if (update.transactions.some(tr => tr.isUserEvent('select') || tr.isUserEvent('input'))) { | ||
| if ( | ||
| update.transactions.some( | ||
| tr => tr.isUserEvent('select') || tr.isUserEvent('input') || tr.isUserEvent('delete') |
Contributor
Author
There was a problem hiding this comment.
I added tr.isUserEvent('delete') here too to fix displaying the suggestions in the React app.
Comment on lines
+55
to
+57
| return queryState | ||
| .setQuery(appendFilter(queryState.query, 'repo', `has.topic(${topic})`)) | ||
| .toSearchURLQueryParamaters() |
Contributor
Author
There was a problem hiding this comment.
Some refactoring here to make it less awkward to use the API (otherwise undefined would have to be passed for search context, which is not obvious).
Comment on lines
+105
to
+107
| public toSearchURLQueryParamaters(): string { | ||
| return buildSearchURLQuery(this.query, this.patternType, this.caseSensitive, undefined, this.searchMode) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Encapsulates the fact that undefined should be passed for search context.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes srch-103
Currently we don't show the global context filter on the search home page or the search results page (global context is the default context).
This commit does two things:
In other words we simplify the query logic by showing/submitting the search query as is. Notably this doesn't affect how the search input works on repo pages.
Test plan
context:filter does not add acontext:filter to the URL or the search inputcontext:globalthat filter is preserved in the query input (it wasn't before)