mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-18 19:19:36 +02:00
Fixed bug where pressing Enter with empty search bar would redirect to search results
This commit is contained in:
parent
0b3eb2e87f
commit
0f6d79683e
4 changed files with 14 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
||||||
### v2.3.0 (TBA)
|
### v2.3.0 (TBA)
|
||||||
- Added custom theme editor ([#246](https://github.com/pawelmalak/flame/issues/246))
|
- Added custom theme editor ([#246](https://github.com/pawelmalak/flame/issues/246))
|
||||||
|
- Fixed bug where pressing Enter with empty search bar would redirect to search results ([#325](https://github.com/pawelmalak/flame/issues/325))
|
||||||
- Fixed bug where user could create empty app or bookmark which was causing page to go blank ([#332](https://github.com/pawelmalak/flame/issues/332))
|
- Fixed bug where user could create empty app or bookmark which was causing page to go blank ([#332](https://github.com/pawelmalak/flame/issues/332))
|
||||||
|
|
||||||
### v2.2.2 (2022-03-21)
|
### v2.2.2 (2022-03-21)
|
||||||
|
|
|
@ -64,7 +64,7 @@ export const SearchBar = (props: Props): JSX.Element => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchHandler = (e: KeyboardEvent<HTMLInputElement>) => {
|
const searchHandler = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||||
const { isLocal, search, query, isURL, sameTab } = searchParser(
|
const { isLocal, search, query, isURL, sameTab, rawQuery } = searchParser(
|
||||||
inputRef.current.value
|
inputRef.current.value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -90,15 +90,18 @@ export const SearchBar = (props: Props): JSX.Element => {
|
||||||
} else if (bookmarkSearchResult?.[0]?.bookmarks?.length) {
|
} else if (bookmarkSearchResult?.[0]?.bookmarks?.length) {
|
||||||
redirectUrl(bookmarkSearchResult[0].bookmarks[0].url, sameTab);
|
redirectUrl(bookmarkSearchResult[0].bookmarks[0].url, sameTab);
|
||||||
} else {
|
} else {
|
||||||
// no local results -> search the internet with the default search provider
|
// no local results -> search the internet with the default search provider if query is not empty
|
||||||
let template = query.template;
|
|
||||||
|
|
||||||
if (query.prefix === 'l') {
|
if (!/^ *$/.test(rawQuery)) {
|
||||||
template = 'https://duckduckgo.com/?q=';
|
let template = query.template;
|
||||||
|
|
||||||
|
if (query.prefix === 'l') {
|
||||||
|
template = 'https://duckduckgo.com/?q=';
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = `${template}${search}`;
|
||||||
|
redirectUrl(url, sameTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${template}${search}`;
|
|
||||||
redirectUrl(url, sameTab);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Valid query -> redirect to search results
|
// Valid query -> redirect to search results
|
||||||
|
|
|
@ -6,4 +6,5 @@ export interface SearchResult {
|
||||||
sameTab: boolean;
|
sameTab: boolean;
|
||||||
search: string;
|
search: string;
|
||||||
query: Query;
|
query: Query;
|
||||||
|
rawQuery: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ export const searchParser = (searchQuery: string): SearchResult => {
|
||||||
prefix: '',
|
prefix: '',
|
||||||
template: '',
|
template: '',
|
||||||
},
|
},
|
||||||
|
rawQuery: searchQuery,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { customQueries, config } = store.getState().config;
|
const { customQueries, config } = store.getState().config;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue