Skip to content

Commit

Permalink
fix(search-pad): close on outside interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Jun 5, 2024
1 parent a70962a commit 9bf8d23
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/features/search-pad/SearchPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ export default function SearchPad(canvas, eventBus, selection, translate) {
// attach search pad
this._canvas.getContainer().appendChild(this._container);

// cleanup on destroy
eventBus.on([ 'canvas.destroy', 'diagram.destroy' ], this.close, this);
// cleanup whenever appropriate
eventBus.on([
'canvas.destroy',
'diagram.destroy',
'drag.init',
'elements.changed'
], this.close, this);
}


Expand Down
28 changes: 28 additions & 0 deletions test/spec/features/search-pad/SearchPadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,34 @@ describe('features/searchPad', function() {
}));


it('should close on <drag.init>', inject(function(eventBus, searchPad) {

// given
searchPad.open();

// when
eventBus.fire('drag.init');

// then
expect(searchPad.isOpen()).to.equal(false);
expect(capturedEvents).to.eql([ EVENTS.opened, EVENTS.closed ]);
}));


it('should close on <elements.changed>', inject(function(eventBus, searchPad) {

// given
searchPad.open();

// when
eventBus.fire('elements.changed');

// then
expect(searchPad.isOpen()).to.equal(false);
expect(capturedEvents).to.eql([ EVENTS.opened, EVENTS.closed ]);
}));


it('should toggle open/close', inject(function(searchPad) {

// when
Expand Down

0 comments on commit 9bf8d23

Please sign in to comment.