From 0bf1ff1d2e34e657ba7a36f692a2401161f2c3ba Mon Sep 17 00:00:00 2001 From: canella riccardo Date: Mon, 2 Oct 2017 12:32:20 +0200 Subject: [PATCH] added id in the input select --- CHANGES.md | 5 +++++ examples/src/components/States.js | 2 +- src/Select.js | 11 ++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 451b929481..ee7a348693 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,3 +31,8 @@ complex option values are much better supported now, won't throw duplicate key e ## Notes `undefined` default props are no longer declared + + +## Added the id custom value + +Now you can add an id to the select element to use it for testing. \ No newline at end of file diff --git a/examples/src/components/States.js b/examples/src/components/States.js index 49dc312525..8c01944fcc 100644 --- a/examples/src/components/States.js +++ b/examples/src/components/States.js @@ -53,7 +53,7 @@ var StatesField = createClass({ return (

{this.props.label}

-
diff --git a/src/Select.js b/src/Select.js index 1c593413e1..7f9cce3ecc 100644 --- a/src/Select.js +++ b/src/Select.js @@ -754,7 +754,6 @@ class Select extends React.Component { && this.state.isFocused && !this.state.inputValue }); - const inputProps = { ...this.props.inputProps, role: 'combobox', @@ -785,8 +784,8 @@ class Select extends React.Component { const ariaOwns = classNames({ [this._instancePrefix + '-list']: isOpen, }); - return ( +
this.input = ref} + id={divProps.id ? divProps.id : this.props.id} aria-readonly={'' + !!this.props.disabled} style={{ border: 0, width: 1, display:'inline-block' }}/> ); @@ -805,12 +805,12 @@ class Select extends React.Component { if (this.props.autosize) { return ( - + ); } return (
- +
); } @@ -1053,8 +1053,8 @@ Select.propTypes = { addLabelText: PropTypes.string, // placeholder displayed when you want to add a label on a multi-value input arrowRenderer: PropTypes.func, // Create drop-down caret element autoBlur: PropTypes.bool, // automatically blur the component when an option is selected - autofocus: PropTypes.bool, // deprecated; use autoFocus instead autoFocus: PropTypes.bool, // autofocus the component on mount + autofocus: PropTypes.bool, // deprecated; use autoFocus instead autosize: PropTypes.bool, // whether to enable autosizing or not backspaceRemoves: PropTypes.bool, // whether backspace removes an item if there is no text input backspaceToRemoveMessage: PropTypes.string, // Message to use for screenreaders to press backspace to remove the current item - {label} is replaced with the item label @@ -1070,6 +1070,7 @@ Select.propTypes = { escapeClearsValue: PropTypes.bool, // whether escape clears the value when the menu is closed filterOption: PropTypes.func, // method to filter a single option (option, filterString) filterOptions: PropTypes.any, // boolean to enable default filtering or function to filter the options array ([options], filterString, [values]) + id: PropTypes.string, // String to set at the input the a custom id, you can use it for the browser test ignoreAccents: PropTypes.bool, // whether to strip diacritics when filtering ignoreCase: PropTypes.bool, // whether to perform case-insensitive filtering inputProps: PropTypes.object, // custom attributes for the Input