mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-03 05:04:51 +08:00
Merge pull request #47 from kadirahq/remove-selected-from-options
Remove setting selected in options
This commit is contained in:
commit
83527a8e4c
12
dist/components/types/Select.js
vendored
12
dist/components/types/Select.js
vendored
@ -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',
|
||||
@ -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]);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user