Skip to content

Commit

Permalink
fix(popup-menu): do not filter on whitespace only input
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Nov 21, 2024
1 parent 5a2fd31 commit 0f24e54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/features/popup-menu/PopupMenuComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function PopupMenuComponent(props) {
return originalEntries;
}

if (!value) {
if (!value.trim()) {
return originalEntries.filter(({ rank = 0 }) => rank >= 0);
}

Expand Down
19 changes: 19 additions & 0 deletions test/spec/features/popup-menu/PopupMenuSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0f24e54

Please sign in to comment.