From 0f24e54fe43abd544e1d9e8ed24b9b2c8e232871 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Thu, 21 Nov 2024 14:04:42 +0100 Subject: [PATCH] fix(popup-menu): do not filter on whitespace only input --- lib/features/popup-menu/PopupMenuComponent.js | 2 +- .../spec/features/popup-menu/PopupMenuSpec.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/features/popup-menu/PopupMenuComponent.js b/lib/features/popup-menu/PopupMenuComponent.js index e91d66d3b..03ca10c60 100644 --- a/lib/features/popup-menu/PopupMenuComponent.js +++ b/lib/features/popup-menu/PopupMenuComponent.js @@ -79,7 +79,7 @@ export default function PopupMenuComponent(props) { return originalEntries; } - if (!value) { + if (!value.trim()) { return originalEntries.filter(({ rank = 0 }) => rank >= 0); } diff --git a/test/spec/features/popup-menu/PopupMenuSpec.js b/test/spec/features/popup-menu/PopupMenuSpec.js index 45b0c585d..dd26f57cc 100755 --- a/test/spec/features/popup-menu/PopupMenuSpec.js +++ b/test/spec/features/popup-menu/PopupMenuSpec.js @@ -1531,6 +1531,25 @@ describe('features/popup-menu', function() { })); + it('should handle whitespace only search', inject(async function(popupMenu) { + + // given + popupMenu.registerProvider('test-menu', testMenuProvider); + popupMenu.open({}, 'test-menu', { x: 100, y: 100 }, { search: true }); + + // when + await triggerSearch(' '); + + // then + await waitFor(() => { + const shownEntries = queryPopupAll('.entry'); + + // just ignores it + expect(shownEntries).to.have.length(5); + }); + })); + + describe('ranking', function() { it('should hide rank < 0 items', inject(async function(popupMenu) {