Skip to content

Commit

Permalink
Fix components randomly disappearing after noresults searches (#1371)
Browse files Browse the repository at this point in the history
#1366
#1367

J=SLAP-1238
  • Loading branch information
oshi97 committed Apr 9, 2021
1 parent e7dc469 commit c6cbee1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/ui/components/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ export default class Component {
this.moduleId = null;

/**
* Unique name of this component instance
* Used to distinguish between other components of the same type
* A unique id number for the component.
* @type {number}
*/
this.uniqueId = systemConfig.uniqueId;

/**
* Name of this component instance.
* @type {String}
*/
this.name = config.name || this.constructor.type;
Expand Down
15 changes: 12 additions & 3 deletions src/ui/components/componentmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default class ComponentManager {
*/
this._activeComponents = [];

/**
* A counter for the id the give to the next component that is created.
*/
this._componentIdCounter = 0;

/**
* A local reference to the core library dependency
*
Expand Down Expand Up @@ -109,8 +114,10 @@ export default class ComponentManager {
core: this._core,
renderer: this._renderer,
analyticsReporter: this._analyticsReporter,
componentManager: this
componentManager: this,
uniqueId: this._componentIdCounter
};
this._componentIdCounter++;

let componentClass = COMPONENT_REGISTRY[componentType];
if (!componentClass) {
Expand Down Expand Up @@ -169,8 +176,10 @@ export default class ComponentManager {
remove (component) {
this._core.globalStorage.off('update', component.moduleId);

const index = this._activeComponents.findIndex(c => c.name === component.name);
this._activeComponents.splice(index, 1);
const index = this._activeComponents.findIndex(c => c.uniqueId === component.uniqueId);
if (index !== -1) {
this._activeComponents.splice(index, 1);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/ui/components/filters/facetscomponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export default class FacetsComponent extends Component {

if (this._filterbox) {
this._filterbox.remove();
this._filterbox = null;
}

let { filters, resultsContext } = this._state.get();
Expand Down

0 comments on commit c6cbee1

Please sign in to comment.