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

Skip rendering arrow wrapper when custom arrow renderer returns falsy value #2055

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
4 changes: 4 additions & 0 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,10 @@ class Select extends React.Component {
const isOpen = this.state.isOpen;
const arrow = this.props.arrowRenderer({ onMouseDown, isOpen });

if (!arrow) {
return null;
}

return (
<span
className="Select-arrow-zone"
Expand Down
18 changes: 18 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3782,6 +3782,24 @@ describe('Select', () => {
});
});

describe('custom arrowRenderer option', () => {
it('should render the custom arrow', () => {
const instance = createControl({
options: [1,2,3],
arrowRenderer: () => <div className="customArrow" />
});
expect(ReactDOM.findDOMNode(instance), 'to contain elements matching', '.customArrow');
});

it('should not render the clickable arrow container if the arrowRenderer returns a falsy value', () => {
const instance = createControl({
options: [1,2,3],
arrowRenderer: () => null
});
expect(ReactDOM.findDOMNode(instance), 'to contain no elements matching', '.Select-arrow-zone');
});
});

describe('accessibility', () => {

describe('with basic searchable control', () => {
Expand Down