Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Data for rendering the tree select items. The object requires the following stru
actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)
dataset, // optional: Allows data-* attributes to be set on the node and tag elements
isDefaultValue, // optional: Indicate if a node is a default value. When true, the dropdown will automatically select the node(s) when there is no other selected node. Can be used on more than one node.
tagLabel, // optional: tag label in case you need it to differ from the checkbox label
... // optional: Any extra properties that you'd like to receive during `onChange` event
}
```
Expand Down
32 changes: 32 additions & 0 deletions __snapshots__/src/tags/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,35 @@ Generated by [AVA](https://ava.li).
<Input />
</li>
</ul>

## should render the tagLabel instead of label when provided

> Snapshot 1

<ul
className="tag-list"
>
<li
className="tag-item"
key="tag-item-i1"
>
<Tag
id="i1"
label="custom label"
/>
</li>
<li
className="tag-item"
key="tag-item-i2"
>
<Tag
id="i2"
label="l2"
/>
</li>
<li
className="tag-item"
>
<Input />
</li>
</ul>
Binary file modified __snapshots__/src/tags/index.test.js.snap
Binary file not shown.
4 changes: 2 additions & 2 deletions src/tags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import './index.css'

const getTags = (tags = [], onDelete, readOnly, disabled, labelRemove) =>
tags.map(tag => {
const { _id, label, tagClassName, dataset } = tag
const { _id, label, tagClassName, dataset, tagLabel } = tag
return (
<li
className={['tag-item', tagClassName].filter(Boolean).join(' ')}
key={`tag-item-${_id}`}
{...getDataset(dataset)}
>
<Tag
label={label}
label={tagLabel || label}
id={_id}
onDelete={onDelete}
readOnly={readOnly}
Expand Down
12 changes: 12 additions & 0 deletions src/tags/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ test('should render data attributes', t => {

t.snapshot(wrapper)
})

test('should render the tagLabel instead of label when provided', t => {
const tags = [{ _id: 'i1', label: 'l1', tagLabel: 'custom label' }, { _id: 'i2', label: 'l2' }]
const wrapper = toJson(
shallow(
<Tags tags={tags}>
<Input />
</Tags>
)
)
t.snapshot(wrapper)
})