From f0228a3947e2f8d9bdc1dd6e5bbdd0c6e7adfc8f Mon Sep 17 00:00:00 2001 From: Linh Nguyen Date: Wed, 8 May 2024 13:32:06 -0700 Subject: [PATCH] Match key state handling to onClick (#2816) --- src/components/search/SearchResults.svelte | 64 +++++++++++----------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/components/search/SearchResults.svelte b/src/components/search/SearchResults.svelte index 1faa8eb5b..c6d18e279 100644 --- a/src/components/search/SearchResults.svelte +++ b/src/components/search/SearchResults.svelte @@ -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) { @@ -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 } @@ -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