Skip to content

Commit

Permalink
fix(index): support custom UI params in UI state warning (#4165)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Oct 23, 2019
1 parent feb2040 commit 80d32fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/lib/__tests__/InstantSearch-test.js
Expand Up @@ -1264,6 +1264,13 @@ describe('UI state', () => {
menu: {
category: 'Hardware',
},
// This is a UI parameter that is not supported by default but that
// can be added when using custom widgets. Having it in `initialUiState`
// makes sure that it doesn't throw if it happens.
anotherWidget: {
query: 'Paris',
location: ['1', '1'],
},
},
},
});
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/index/index.ts
Expand Up @@ -391,10 +391,11 @@ const index = (props: IndexProps): Index => {
const missingWidgets = Object.keys(localUiState).reduce<
MissingWidgets
>((acc, parameter) => {
const requiredWidgets: Array<Widget['$$type']> =
const requiredWidgets: Array<Widget['$$type']> | undefined =
stateToWidgetsMap[parameter];

if (
requiredWidgets &&
!requiredWidgets.some(requiredWidget =>
mountedWidgets.includes(requiredWidget)
)
Expand Down

0 comments on commit 80d32fc

Please sign in to comment.