From 581833c5ff77ec86d0f706de4496bde14a918688 Mon Sep 17 00:00:00 2001 From: Patrick Wolfert Date: Mon, 2 Apr 2018 10:04:50 -0700 Subject: [PATCH] Adds an optional className prop to Autocomplete and appropriate tests (#263) --- .../src/components/Autocomplete/Autocomplete.jsx | 15 ++++++++++++++- .../components/Autocomplete/Autocomplete.test.jsx | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/core/src/components/Autocomplete/Autocomplete.jsx b/packages/core/src/components/Autocomplete/Autocomplete.jsx index 62515ba3b6..0a47eb68e1 100644 --- a/packages/core/src/components/Autocomplete/Autocomplete.jsx +++ b/packages/core/src/components/Autocomplete/Autocomplete.jsx @@ -4,6 +4,7 @@ import Downshift from 'downshift'; import PropTypes from 'prop-types'; import React from 'react'; import TextField from '../TextField/TextField'; +import classNames from 'classnames'; import uniqueId from 'lodash.uniqueid'; /** @@ -95,9 +96,16 @@ export class Autocomplete extends React.PureComponent { label, loading, children, + className, ...autocompleteProps } = this.props; + const rootClassName = classNames( + 'ds-u-clearfix', + 'ds-c-autocomplete', + className + ); + return ( ( -
+
{this.renderChildren(getInputProps)} {isOpen && (loading || items) ? ( @@ -171,6 +179,11 @@ Autocomplete.propTypes = { */ ariaClearLabel: PropTypes.string, children: PropTypes.node, + /** + * Additional classes to be added to the root element. + * Useful for adding utility classes. + */ + className: PropTypes.string, /** * Clear search text that will appear on the page as part of the rendered `