Skip to content

Commit

Permalink
fix(popup-menu): do not search by entry id
Browse files Browse the repository at this point in the history
  • Loading branch information
smbea committed Dec 8, 2022
1 parent f0ea636 commit 8d03192
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/features/popup-menu/PopupMenuComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ export default function PopupMenuComponent(props) {
}

const search = [
entry.name,
entry.description || '',
entry.label || '',
entry.id || ''
entry.label || ''
]
.join('---')
.toLowerCase();
Expand Down
43 changes: 41 additions & 2 deletions test/spec/features/popup-menu/PopupMenuComponentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ describe('features/popup-menu - <PopupMenu>', function() {
describe('search', function() {

const entries = [
{ id: '1', label: 'Entry 1' },
{ id: '1', label: 'Entry 1', description: 'Entry 1 description' },
{ id: '2', label: 'Entry 2' },
{ id: '3', label: 'Entry 3' },
{ id: '4', label: 'Entry 4' },
{ id: '5', label: 'Entry 5' },
{ id: '6', label: 'Last' }
{ id: 'some_entry_id', label: 'Last' }
];


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


it('should search description', async function() {

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

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

// 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 1');
});


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

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

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

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

await whenStable();

// then
expect(domQueryAll('.entry', container)).to.have.length(0);
});


describe('render', function() {

const otherEntries = [
Expand Down

0 comments on commit 8d03192

Please sign in to comment.