Skip to content

Commit 53a43dd

Browse files
nikkuBuckwich
authored andcommitted
feat(popup-menu): prioritize search over description when matching entries
1 parent b95ff6f commit 53a43dd

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

lib/features/popup-menu/PopupMenuComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export default function PopupMenuComponent(props) {
8888
return searchFn(searchableEntries, searchValue, {
8989
keys: [
9090
'label',
91-
'description',
92-
'search'
91+
'search',
92+
'description'
9393
]
9494
}).map(({ item }) => item);
9595
}, [ searchable ]);

test/spec/features/popup-menu/PopupMenuSpec.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,51 @@ describe('features/popup-menu', function() {
14951495
}));
14961496

14971497

1498+
it('should show search results (prioritizing search over description)', inject(async function(popupMenu) {
1499+
1500+
// given
1501+
popupMenu.registerProvider('test-menu', {
1502+
getEntries: function() {
1503+
return [
1504+
{
1505+
id: 'search',
1506+
label: 'First',
1507+
search: 'search'
1508+
},
1509+
{
1510+
id: 'description',
1511+
label: 'Second',
1512+
description: 'search things'
1513+
},
1514+
{
1515+
id: 'other-1',
1516+
label: 'Other 1'
1517+
},
1518+
{
1519+
id: 'other-2',
1520+
label: 'Other 2'
1521+
},
1522+
{
1523+
id: 'other-3',
1524+
label: 'Other 3'
1525+
},
1526+
{
1527+
id: 'other-4',
1528+
label: 'Other 4'
1529+
}
1530+
];
1531+
}
1532+
});
1533+
popupMenu.open({}, 'test-menu', { x: 100, y: 100 }, { search: true });
1534+
1535+
// when
1536+
await triggerSearch('search');
1537+
1538+
// then
1539+
await expectEntries([ 'First', 'Second' ]);
1540+
}));
1541+
1542+
14981543
it('should show search results (matching label & search)', inject(async function(popupMenu) {
14991544

15001545
// given

0 commit comments

Comments
 (0)