diff --git a/packages/nux/src/store/actions.js b/packages/nux/src/store/actions.js index 3ee9c8e142a89..c29fbfd0ed290 100644 --- a/packages/nux/src/store/actions.js +++ b/packages/nux/src/store/actions.js @@ -14,7 +14,7 @@ export function triggerGuide( tipIds ) { } /** - * Returns an action object that, when dispathed, associates an instance of the + * Returns an action object that, when dispatched, associates an instance of the * DotTip component with a tip. This is usually done when the component mounts. * Tracking this lets us only show one DotTip at a time per tip. * diff --git a/packages/nux/src/store/reducer.js b/packages/nux/src/store/reducer.js index 2383fee47b4ef..24096aeaee8a5 100644 --- a/packages/nux/src/store/reducer.js +++ b/packages/nux/src/store/reducer.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { union, without } from 'lodash'; +import { uniq, without } from 'lodash'; /** * WordPress dependencies @@ -41,11 +41,13 @@ export function guides( state = [], action ) { */ export function tipInstanceIds( state = {}, action ) { switch ( action.type ) { - case 'REGISTER_TIP_INSTANCE': + case 'REGISTER_TIP_INSTANCE': { + const existingInstanceIds = state[ action.tipId ] || []; return { ...state, - [ action.tipId ]: union( state[ action.tipId ] || [], [ action.instanceId ] ), + [ action.tipId ]: uniq( [ ...existingInstanceIds, action.instanceId ] ), }; + } case 'UNREGISTER_TIP_INSTANCE': return {