Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Dropdown): noResultsMessage prop can be a node #3177

Merged
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
2 changes: 1 addition & 1 deletion src/modules/Dropdown/Dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export interface StrictDropdownProps {
multiple?: boolean

/** Message to display when there are no results. */
noResultsMessage?: string
noResultsMessage?: React.ReactNode

/**
* Called when a user adds a new item. Use this to update the options list.
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class Dropdown extends Component {
multiple: PropTypes.bool,

/** Message to display when there are no results. */
noResultsMessage: PropTypes.string,
noResultsMessage: PropTypes.node,

/**
* Called when a user adds a new item. Use this to update the options list.
Expand Down
18 changes: 17 additions & 1 deletion test/specs/modules/Dropdown/Dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ describe('Dropdown', () => {
wrapper.find('.message').should.have.text('No results found.')
})

it('uses custom noResultsMessage', () => {
it('uses custom string for noResultsMessage', () => {
const search = wrapperMount(
<Dropdown options={options} selection search noResultsMessage='Something custom' />,
).find('input.search')
Expand All @@ -2110,6 +2110,22 @@ describe('Dropdown', () => {
wrapper.find('.message').should.have.text('Something custom')
})

it('uses custom component for noResultsMessage', () => {
const search = wrapperMount(
<Dropdown
options={options}
selection
search
noResultsMessage={<span>Something custom</span>}
/>,
).find('input.search')

// search for something we know will not exist
search.simulate('change', { target: { value: '_________________' } })

wrapper.find('.message').should.contain.descendants('span')
})

it('uses no noResultsMessage', () => {
const search = wrapperMount(
<Dropdown options={options} selection search noResultsMessage='' />,
Expand Down