Skip to content

Commit

Permalink
Make search global (#2878)
Browse files Browse the repository at this point in the history
Fixes #2626
This updates the way search is handled if there is an opened tag to match the other platforms.
Currently, if there is a tag selected the search is restricted to that tag.
This updates so that whenever a search is placed it is for all notes. Searches can still be restricted to tags using the syntax tag:recipe in the search field.
  • Loading branch information
sandymcfadden authored May 1, 2021
1 parent 54ca503 commit ec8b3aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/search-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ export class SearchField extends Component<Props> {
const { openedTag, searchQuery } = this.props;
const hasQuery = searchQuery.length > 0;

const description =
'Search ' + (openedTag ? 'notes in ' + openedTag : 'notes and tags');

return (
<div className="search-field theme-color-fg theme-color-border">
<button
Expand All @@ -89,7 +86,7 @@ export class SearchField extends Component<Props> {
<input
ref={this.inputField}
type="search"
placeholder={description}
placeholder="Search all notes and tags"
onChange={this.update}
onKeyUp={this.interceptEsc}
value={searchQuery}
Expand Down
7 changes: 6 additions & 1 deletion lib/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ export const middleware: S.Middleware = (store) => {
}

const openedTagHash = collection.type === 'tag' && t(collection.tagName);
if (openedTagHash && !note.tags.has(openedTagHash)) {
if (
searchTerms.length === 0 &&
searchTags.size === 0 &&
openedTagHash &&
!note.tags.has(openedTagHash)
) {
continue;
}

Expand Down

0 comments on commit ec8b3aa

Please sign in to comment.