Skip to content

Commit

Permalink
do not re-render embeddable so often (elastic#95653) (elastic#95812)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
  • Loading branch information
kibanamachine and flash1293 committed Mar 30, 2021
1 parent 0f488c4 commit f39f67a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,13 @@ describe('embeddable', () => {
expect(expressionRenderer).toHaveBeenCalledTimes(2);
});

it('should re-render when dashboard view/edit mode changes', async () => {
it('should re-render when dashboard view/edit mode changes if dynamic actions are set', async () => {
const sampleInput = ({
id: '123',
enhancements: {
dynamicActions: {},
},
} as unknown) as LensEmbeddableInput;
const embeddable = new Embeddable(
{
timefilter: dataPluginMock.createSetupContract().query.timefilter.timefilter,
Expand Down Expand Up @@ -371,6 +377,13 @@ describe('embeddable', () => {
viewMode: ViewMode.VIEW,
});

expect(expressionRenderer).toHaveBeenCalledTimes(1);

embeddable.updateInput({
...sampleInput,
viewMode: ViewMode.VIEW,
});

expect(expressionRenderer).toHaveBeenCalledTimes(2);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ export class Embeddable
skip(1)
)
.subscribe((input) => {
this.reload();
// only reload if drilldowns are set
if (this.getInput().enhancements?.dynamicActions) {
this.reload();
}
})
);

Expand Down

0 comments on commit f39f67a

Please sign in to comment.