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

feat(popup-menu): allow additional search terms #745

Merged
merged 1 commit into from
Jan 25, 2023
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
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