Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Merge pull request #47 from kadirahq/remove-selected-from-options
Browse files Browse the repository at this point in the history
Remove setting selected in options
  • Loading branch information
roonyh authored Sep 28, 2016
2 parents 79b0bcd + 538c640 commit 83527a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
12 changes: 3 additions & 9 deletions dist/components/types/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ var SelectType = function (_React$Component) {

(0, _createClass3.default)(SelectType, [{
key: '_makeOpt',
value: function _makeOpt(key, val, selected) {
value: function _makeOpt(key, val) {
var opts = {
key: key,
selected: 'selected',
value: key
};
if (selected !== key) {
delete opts.selected;
}

return _react2.default.createElement(
'option',
Expand All @@ -79,16 +75,14 @@ var SelectType = function (_React$Component) {
value: function _options(values) {
var _this2 = this;

var selected = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];

var data = [];
if (Array.isArray(values)) {
data = values.map(function (val) {
return _this2._makeOpt(val, val, selected);
return _this2._makeOpt(val, val);
});
} else {
data = (0, _keys2.default)(values).map(function (key) {
return _this2._makeOpt(key, values[key], selected);
return _this2._makeOpt(key, values[key]);
});
}

Expand Down
12 changes: 4 additions & 8 deletions src/components/types/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@ const styles = {
};

class SelectType extends React.Component {
_makeOpt(key, val, selected) {
_makeOpt(key, val) {
const opts = {
key,
selected: 'selected',
value: key,
};
if (selected !== key) {
delete(opts.selected);
}

return <option {...opts}>{val}</option>;
}
_options(values, selected = '') {
_options(values) {
let data = [];
if (Array.isArray(values)) {
data = values.map(val => this._makeOpt(val, val, selected));
data = values.map(val => this._makeOpt(val, val));
} else {
data = Object.keys(values).map(key => this._makeOpt(key, values[key], selected));
data = Object.keys(values).map(key => this._makeOpt(key, values[key]));
}

return data;
Expand Down

0 comments on commit 83527a8

Please sign in to comment.