Skip to content

Commit

Permalink
feat(popup-menu): allow additional search terms
Browse files Browse the repository at this point in the history
  • Loading branch information
smbea committed Jan 25, 2023
1 parent 8966c4e commit 6125c80
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/features/popup-menu/PopupMenuComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export default function PopupMenuComponent(props) {

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

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


it('should search additional "search" terms', async function() {

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

var searchInput = domQuery('.djs-popup-search input', container);
searchInput.value = entries[4].search;

// when
searchInput.dispatchEvent(keyDown('ArrowUp'));
searchInput.dispatchEvent(keyUp('ArrowUp'));

await whenStable();

// then
expect(domQueryAll('.entry', container)).to.have.length(1);
expect(domQuery('.entry .djs-popup-label', container).textContent).to.eql('Entry 5');
});


it('should not search id', async function() {

// given
Expand Down

0 comments on commit 6125c80

Please sign in to comment.