Skip to content

Commit

Permalink
[Labs / MultiSelect] Allow tags to be arbitrary elements (#1465)
Browse files Browse the repository at this point in the history
* Fix and unit test

* Update multiSelect.tsx

* Update multiSelectTests.tsx
  • Loading branch information
sushain97 authored and cmslewis committed Aug 22, 2017
1 parent 06d9cb0 commit 7fd70b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/labs/src/components/select/multiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export interface IMultiSelectProps<T> extends IListItemsProps<T> {
/** Props to spread to `TagInput`. */
tagInputProps?: Partial<ITagInputProps> & object;

/** Custom renderer to transform an item into a string for tags. */
tagRenderer: (item: T) => string;
/** Custom renderer to transform an item into tag content. */
tagRenderer: (item: T) => React.ReactNode;
}

export interface IMultiSelectState<T> {
Expand Down
7 changes: 6 additions & 1 deletion packages/labs/test/multiSelectTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* and https://github.com/palantir/blueprint/blob/master/PATENTS
*/

import { Classes, MenuItem } from "@blueprintjs/core";
import { Classes, MenuItem, Tag } from "@blueprintjs/core";
import { assert } from "chai";
import * as classNames from "classnames";
import { mount } from "enzyme";
Expand Down Expand Up @@ -44,6 +44,11 @@ describe("<MultiSelect>", () => {
assert.equal((input.getDOMNode() as HTMLInputElement).placeholder, placeholder);
});

it("tagRenderer can return JSX", () => {
const wrapper = multiselect({ tagRenderer: (film) => <strong>{film.title}</strong>, selectedItems: [TOP_100_FILMS[0]] });
assert.equal(wrapper.find(Tag).find("strong").length, 1);
});

it("clicking item invokes onSelectItem with placeholder", () => {
const placeholder = "look here";

Expand Down

0 comments on commit 7fd70b3

Please sign in to comment.