Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@1ac2d7b from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 8, 2024
1 parent 6511baf commit b16e092
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions includes/facets/blocks/facets-context-provider/src/view.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/**
* WordPress Dependencies
*/
import {
store,
navigate,
prefetch,
getElement,
getContext,
} from '@wordpress/interactivity';
import { store, getElement, getContext } from '@wordpress/interactivity';

// @TODO: Faking the wordpress/url package import for now, until the new Gutenberg Module Loader is completed.
const { addQueryArgs } = window.wp.url;
Expand Down Expand Up @@ -137,17 +131,23 @@ const { context, state, actions } = store(
state.selected[facetSlug] = [value];
}
},
onCheckboxMouseEnter: () => {
*onCheckboxMouseEnter() {
console.log(
'prc-platform/facets-context-provider',
'onCheckboxMouseEnter'
);
const router = yield import('@wordpress/interactivity-router');
const newUrl = '';
yield router.actions.prefetch(newUrl);
},
onButtonMouseEnter: () => {
*onButtonMouseEnter() {
console.log(
'prc-platform/facets-context-provider',
'onButtonMouseEnter'
);
const router = yield import('@wordpress/interactivity-router');
const newUrl = '';
yield router.actions.prefetch(newUrl);
},
onClear: (facetSlug) => {
console.log('onClear', facetSlug, state);
Expand Down Expand Up @@ -180,12 +180,13 @@ const { context, state, actions } = store(
context
);
},
onSelection: async () => {
*onSelection() {
const selected = state.getSelected;
console.log('onSelection', selected);
if (undefined === selected) {
return;
}
const router = yield import('@wordpress/interactivity-router');
// Only if the selection has some values.
if (Object.keys(selected).length > 0) {
const newUrl = state.getUpdatedUrl;
Expand All @@ -200,15 +201,15 @@ const { context, state, actions } = store(
);
}, state.navigateTimer);

await navigate(newUrl);
yield router.actions.navigate(newUrl);

clearTimeout(timeout);

state.isProcessing = false;
} else {
// If there are no selections, then we need to navigate to the base url.
const newUrl = window.location.href.split('?')[0];
await navigate(newUrl);
yield router.actions.navigate(newUrl);
}
},
},
Expand Down

0 comments on commit b16e092

Please sign in to comment.