Skip to content

Commit

Permalink
fix(search-pad): reduce padding
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 23, 2024
1 parent dc5d5a8 commit 7340ee8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lib/features/search-pad/SearchPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { isKey } from '../keyboard/KeyboardUtil';
* @typedef {import('./SearchPadProvider').Token} Token
*/

var SCROLL_TO_ELEMENT_PADDING = 300;

/**
* Provides searching infrastructure.
*
Expand Down Expand Up @@ -446,7 +448,7 @@ SearchPad.prototype._preselect = function(node) {
domClasses(node).add(SearchPad.RESULT_SELECTED_CLASS);

this._canvas.scrollToElement(element, {
top: 300
top: SCROLL_TO_ELEMENT_PADDING
});

this._selection.select(element);
Expand All @@ -471,8 +473,6 @@ SearchPad.prototype._select = function(node) {

this.close(false);

this._canvas.scrollToElement(element, { top: 400 });

this._selection.select(element);

this._eventBus.fire('searchPad.selected', element);
Expand Down
23 changes: 10 additions & 13 deletions test/spec/features/search-pad/SearchPadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,23 @@ describe('features/searchPad', function() {
it('select should scroll element into view', inject(function(canvas) {

// given
typeText(input_node, 'one');
const container = canvas.getContainer();

var container = canvas.getContainer();
container.style.width = '1000px';
container.style.height = '1000px';
container.style.width = '500px';
container.style.height = '500px';

canvas.viewbox({
x: 1000,
y: 1000,
width: 1000,
height: 1000
});
canvas.scroll({ dx: 10000, dy: 10000 });

// when
typeText(input_node, 'one');

triggerKeyEvent(input_node, 'keyup', 'Enter');

// then
var newViewbox = canvas.viewbox();
expect(newViewbox).to.have.property('x', -100);
expect(newViewbox).to.have.property('y', -400);
var viewbox = canvas.viewbox();

expect(viewbox).to.have.property('x', -100);
expect(viewbox).to.have.property('y', -300);
}));


Expand Down

0 comments on commit 7340ee8

Please sign in to comment.