Skip to content

Commit bbb0ca7

Browse files
committed
Add boolean support. Fixes #164
1 parent 125cc76 commit bbb0ca7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/TreeView/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export const getAccessibleRange = ({
290290
/**
291291
* This is to help consumers to understand that we do not currently support metadata that is a nested object. If this is needed, make an issue in Github
292292
*/
293-
export type IFlatMetadata = Record<string, string | number | undefined | null>;
293+
export type IFlatMetadata = Record<string, string | number | boolean | undefined | null>;
294294

295295
interface ITreeNode<M extends IFlatMetadata> {
296296
id?: NodeId;

src/__tests__/TreeViewMetadata.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ const initialTreeNode = {
1313
name: "Fruits",
1414
id: 54,
1515
children: [
16-
{ name: "Avocados", id: 98, metadata: { color: 'green' } },
17-
{ name: "Bananas", id: 789, metadata: { color: 'yellow' } },
16+
{ name: "Avocados", id: 98, metadata: { color: 'green', available: true } },
17+
{ name: "Bananas", id: 789, metadata: { color: 'yellow', available: false } },
1818
],
1919
},
2020
{
2121
id: 888,
2222
name: "Drinks",
2323
children: [
24-
{ name: "Apple Juice", id: 990, metadata: { color: 'yellow' } },
25-
{ name: "Coffee", id: 9 , metadata: { color: 'brown' }},
24+
{ name: "Apple Juice", id: 990, metadata: { color: 'yellow', available: true } },
25+
{ name: "Coffee", id: 9 , metadata: { color: 'brown', available: true }},
2626
{
2727
id: 43,
2828
name: "Tea",
2929
children: [
30-
{ name: "Black Tea", id: 4, metadata: { color: 'black' } },
31-
{ name: "Green Tea", id: 44, metadata: { color: 'green' } },
30+
{ name: "Black Tea", id: 4, metadata: { color: 'black', available: false } },
31+
{ name: "Green Tea", id: 44, metadata: { color: 'green', available: false } },
3232
{
3333
id: 53,
3434
name: "Matcha",
35-
metadata: { color: 'green' },
36-
children: [{ name: "Matcha 1", id: 2, metadata: { color: 'green' } }],
35+
metadata: { color: 'green', available: true },
36+
children: [{ name: "Matcha 1", id: 2, metadata: { color: 'green', available: false } }],
3737
},
3838
],
3939
},
@@ -101,7 +101,7 @@ function TreeViewMetadata(props: TreeViewDataTypeProps) {
101101
const thisNodesMetadata = nodeData.metadata;
102102
if (thisNodesMetadata !== undefined) {
103103
const node = nodes.find((x) => {
104-
return x.innerHTML.includes(`${thisNodesMetadata.color}`)
104+
return x.innerHTML.includes(`${thisNodesMetadata.color}`) && x.innerHTML.includes(`${thisNodesMetadata.available}`)
105105
});
106106
expect(node).toBeDefined;
107107
} else {

0 commit comments

Comments
 (0)