landscape: sort Leap search results alphabetically
@@ -245,6 +245,15 @@ export function Omnibox(props: OmniboxProps) {
setQuery(event.target.value);
}, []);
+ // Sort Omnibox results alphabetically
+ const sortResults = (a: Record<'title', string>, b: Record<'title', string>) => {
+ // Do not sort unless searching (preserves order of menu actions)
+ if (query === '') { return 0 };
+ if (a.title < b.title) { return -1 };
+ if (a.title > b.title) { return 1 };
+ return 0;
+ }
+
const renderResults = useCallback(() => {
return <Box
maxHeight={['200px', '400px']}
@@ -262,7 +271,9 @@ export function Omnibox(props: OmniboxProps) {
const sel = selected?.length ? selected[1] : '';
return (<Box key={i} width='max(50vw, 300px)' maxWidth='600px'>
{categoryTitle}
- {categoryResults.map((result, i2) => (
+ {categoryResults
+ .sort(sortResults)
+ .map((result, i2) => (
<OmniboxResult
key={i2}
icon={result.app}
