Skip to content

Commit

Permalink
🐛 Fix bug when creating dataview in place
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Aug 10, 2022
1 parent e68a013 commit d594e09
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,29 @@ export const LensTopNavMenu = ({
);
const dispatchChangeIndexPattern = React.useCallback(
async (indexPatternId) => {
const newIndexPatterns = await indexPatternService.ensureIndexPattern({
id: indexPatternId,
cache: dataViews.indexPatterns,
});
const [newIndexPatternRefs, newIndexPatterns] = await Promise.all([
// Reload refs in case it's a new indexPattern created on the spot
dataViews.indexPatternRefs[indexPatternId]
? dataViews.indexPatternRefs
: indexPatternService.loadIndexPatternRefs({
isFullEditor: true,
}),
indexPatternService.ensureIndexPattern({
id: indexPatternId,
cache: dataViews.indexPatterns,
}),
]);
dispatch(
changeIndexPattern({
dataViews: { indexPatterns: newIndexPatterns },
dataViews: { indexPatterns: newIndexPatterns, indexPatternRefs: newIndexPatternRefs },
datasourceIds: Object.keys(datasourceStates),
visualizationIds: visualization.activeId ? [visualization.activeId] : [],
indexPatternId,
})
);
},
[
dataViews.indexPatternRefs,
dataViews.indexPatterns,
datasourceStates,
dispatch,
Expand Down

0 comments on commit d594e09

Please sign in to comment.