Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(popup-menu): do not search by entry id #720

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
nikku marked this conversation as resolved.
Show resolved Hide resolved
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' }
nikku marked this conversation as resolved.
Show resolved Hide resolved
];


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