Skip to content

Commit

Permalink
feat(popup): allow non-searchable entries
Browse files Browse the repository at this point in the history
Closs #834
  • Loading branch information
smbea committed Dec 4, 2023
1 parent 4d00fc1 commit de4c598
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/features/popup-menu/PopupMenuComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export default function PopupMenuComponent(props) {
return (entry.rank || 0) >= 0;
}

if (entry.searchable === false) {
return 0;
}

const search = [
entry.description || '',
entry.label || '',
Expand Down
20 changes: 19 additions & 1 deletion test/spec/features/popup-menu/PopupMenuComponentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ describe('features/popup-menu - <PopupMenu>', function() {
{ id: '3', label: 'Entry 3' },
{ id: '4', label: 'Entry 4' },
{ id: '5', label: 'Entry 5', search: 'foo' },
{ id: 'some_entry_id', label: 'Last' }
{ id: 'some_entry_id', label: 'Last' },
{ id: '7', label: 'Entry 7' , searchable: false }
];


Expand Down Expand Up @@ -544,6 +545,23 @@ describe('features/popup-menu - <PopupMenu>', function() {
});


it('should not search non-searchable entries', async function() {

// given
await createPopupMenu({ container, entries, search: true });

var searchInput = domQuery('.djs-popup-search input', container);
searchInput.value = 'entry';

// when
await trigger(searchInput, keyDown('ArrowUp'));
await trigger(searchInput, keyUp('ArrowUp'));

// then
expect(domQuery('.entry[data-id="7"]', container)).to.not.exist;
});


describe('render', function() {

const otherEntries = [
Expand Down

0 comments on commit de4c598

Please sign in to comment.