Skip to content

Commit

Permalink
Match key state handling to onClick (#2816)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iinh authored May 8, 2024
1 parent bc643d8 commit f0228a3
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions src/components/search/SearchResults.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,35 @@
}
};
const getProductDimensions = (result) => {
if (result.glean) {
// we have to manually set the product dimensions for FOG and Fenix to avoid them automatically picking up the Firefox legacy dimensions
store.setField('product', 'fog');
store.setField('productDimensions', {
app_id: 'nightly',
os: '*',
ping_type: '*',
aggregationLevel: 'build_id',
});
return 'fog';
}
if ($store.searchProduct === 'fenix') {
store.setField('product', 'fenix');
store.setField('productDimensions', {
app_id: 'nightly',
os: 'Android',
ping_type: 'metrics',
aggregationLevel: 'build_id',
});
return 'fenix';
}
if ($store.searchProduct === 'firefox' && !result.glean) {
store.setField('product', 'firefox');
return 'firefox';
}
return undefined;
};
const handleKeypress = (event) => {
const { key } = event;
if (results && searchIsActive && results.length >= 1) {
Expand All @@ -56,9 +85,11 @@
searchIsActive = false;
page.show(
`/${$store.searchProduct}/probe/${results[
`/${getProductDimensions(results[focusedItem])}/probe/${results[
focusedItem
].name.toLowerCase()}/explore?`
].name
.toLowerCase()
.replaceAll('.', '_')}/explore${$currentQuery}`
);
focusedItem = 0; // reset focused element
}
Expand Down Expand Up @@ -92,35 +123,6 @@
width = bounds.width;
}
const getProductDimensions = (result) => {
if (result.glean) {
// we have to manually set the product dimensions for FOG and Fenix to avoid them automatically picking up the Firefox legacy dimensions
store.setField('product', 'fog');
store.setField('productDimensions', {
app_id: 'nightly',
os: '*',
ping_type: '*',
aggregationLevel: 'build_id',
});
return 'fog';
}
if ($store.searchProduct === 'fenix') {
store.setField('product', 'fenix');
store.setField('productDimensions', {
app_id: 'nightly',
os: 'Android',
ping_type: 'metrics',
aggregationLevel: 'build_id',
});
return 'fenix';
}
if ($store.searchProduct === 'firefox' && !result.glean) {
store.setField('product', 'firefox');
return 'firefox';
}
return undefined;
};
const onClick = () => {
// clearing the ref field to avoid the probe explorer
// from trying to load a probe from the URL
Expand Down

0 comments on commit f0228a3

Please sign in to comment.