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,10 +35,8 @@
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';
import { xComponentMixin } from '../../../components/x-component.mixin';
import { NoElement } from '../../../components/no-element';
import { RequestStatus } from '../../../store';
Expand All @@ -49,6 +47,7 @@
import { createOrigin } from '../../../utils/origin';
import { debounce } from '../../../utils/debounce';
import { DebouncedFunction } from '../../../utils';
import { LIST_ITEMS_KEY, XProvide } from '../../../components';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restore this imports as they were before


/**
* Retrieves a preview of the results of a query and exposes them in the default slot,
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 @@ -17,4 +17,8 @@ export interface QueriesPreviewXEvents {
* Payload: The query whose preview has been removed.
*/
QueryPreviewUnmountedHook: string;
/**
* The component that shows a Query preview has been destroyed.
*/
QueriesPreviewDestroyedHook: void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this event

}
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