Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Brand Recommendations animation on second time appearance #1267

Merged
merged 9 commits into from
Sep 12, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import Vue from 'vue';
import { Component, Prop, Inject, Watch } from 'vue-property-decorator';
import { Dictionary } from '@empathyco/x-utils';
import { SearchRequest, Result } from '@empathyco/x-types';
import { Result, SearchRequest } from '@empathyco/x-types';
import { State } from '../../../components/decorators/store.decorators';
import { LIST_ITEMS_KEY } from '../../../components/decorators/injection.consts';
import { XProvide } from '../../../components/decorators/injection.decorators';
Expand All @@ -49,7 +49,6 @@
import { createOrigin } from '../../../utils/origin';
import { debounce } from '../../../utils/debounce';
import { DebouncedFunction } from '../../../utils';

/**
* Retrieves a preview of the results of a query and exposes them in the default slot,
* along with the query preview and the totalResults of the search request.
Expand Down Expand Up @@ -98,6 +97,15 @@
@Prop({ default: 0 })
public debounceTimeMs!: number;

/**
* Controls whether the QueryPreview should be removed from the state
* when the component is destroyed.
*
* @public
*/
@Prop({ default: true })
public clearOnDestroy!: boolean;

/**
* The results preview of the queries preview mounted.
* It is a dictionary, indexed by the query preview query.
Expand Down Expand Up @@ -205,11 +213,17 @@
/**
* Cancels the (remaining) requests when the component is destroyed
* via the `debounce.cancel()` method.
* If the prop 'clearOnDestroy' is set to true, it also removes the QueryPreview
* from the state when the component is destroyed.
*
* @internal
*/
protected beforeDestroy(): void {
this.emitQueryPreviewRequestUpdated.cancel();

if (this.clearOnDestroy) {
this.$x.emit('QueryPreviewUnmountedHook', this.query, { priority: 0, replaceable: false });
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const fetchAndSaveQueryPreviewWire = wireDispatch('fetchAndSaveQueryPrevi
*
* @public
*/

export const clearQueryPreviewWire = wireCommit('clearQueryPreview');

/**
Expand Down