From 7340ee82e46151ee69acb5db33186d9d8cf26025 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Mon, 23 Sep 2024 14:24:09 +0200 Subject: [PATCH] fix(search-pad): reduce padding --- lib/features/search-pad/SearchPad.js | 6 ++--- .../spec/features/search-pad/SearchPadSpec.js | 23 ++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/features/search-pad/SearchPad.js b/lib/features/search-pad/SearchPad.js index 28c2aa8c6..bda1abb84 100644 --- a/lib/features/search-pad/SearchPad.js +++ b/lib/features/search-pad/SearchPad.js @@ -26,6 +26,8 @@ import { isKey } from '../keyboard/KeyboardUtil'; * @typedef {import('./SearchPadProvider').Token} Token */ +var SCROLL_TO_ELEMENT_PADDING = 300; + /** * Provides searching infrastructure. * @@ -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); @@ -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); diff --git a/test/spec/features/search-pad/SearchPadSpec.js b/test/spec/features/search-pad/SearchPadSpec.js index c54fa9b93..8121dffde 100644 --- a/test/spec/features/search-pad/SearchPadSpec.js +++ b/test/spec/features/search-pad/SearchPadSpec.js @@ -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); }));