Skip to content

Commit

Permalink
fix: Fix show non-grouped items as undefined (#229)
Browse files Browse the repository at this point in the history
closes #66
  • Loading branch information
janstuemmel authored Jun 15, 2023
1 parent 69b4241 commit 34b8a29
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/common/util/groupBy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ it('should group items by \'group\'', () => {
}, {
foo: '1',
group: 'bar'
}, {
foo: '1',
group: undefined
}];

const grouped = groupBy(config, ['group']);
expect(grouped).toMatchInlineSnapshot(`
{
"": [
{
"foo": "1",
"group": undefined,
},
],
"bar": [
{
"foo": "1",
Expand Down
2 changes: 1 addition & 1 deletion src/common/util/groupBy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const groupBy = <T>(arr: T[], keys: (keyof T)[]): { [key: string]: T[] } => {
return arr.reduce((storage, item) => {
const objKey = keys.map(key => `${ item[key] }`).join(':');
const objKey = keys.map(key => item[key]).join(':');
if (storage[objKey]) {
storage[objKey].push(item);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/popup/components/SectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default <T, >({
return item.type === 'section' ? renderSection({
key,
style,
title: item.title || 'Ungrouped',
title: item.title ? item.title : 'Ungrouped',
}) : renderItem({
key,
style,
Expand Down

0 comments on commit 34b8a29

Please sign in to comment.