Skip to content
This repository was archived by the owner on May 15, 2022. It is now read-only.

Commit badc461

Browse files
Fixed DatSelect component so that it selects the value set in the path from the state by default
1 parent 9958b13 commit badc461

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Each item in this array will need to be in the format `{ 'presetName': ...data,
193193

194194
#### `DatSelect`
195195

196-
A select component for updating a value with one of the options supplied via the `options` prop. The original value from the `path` will always be added to the passed options array as the first item.
196+
A select component for updating a value with one of the options supplied via the `options` prop. The initial selected value will be taken from the mapped `path` prop.
197197

198198
##### props
199199

build/react-dat-gui.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7153,8 +7153,6 @@ var _lodash4 = _interopRequireDefault(_lodash3);
71537153

71547154
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
71557155

7156-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
7157-
71587156
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
71597157

71607158
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@@ -7176,8 +7174,8 @@ var DatSelect = function (_Component) {
71767174
}
71777175

71787176
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DatSelect.__proto__ || Object.getPrototypeOf(DatSelect)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
7179-
value: '',
7180-
options: [_this.getValue()].concat(_toConsumableArray(_this.props.options))
7177+
value: _this.getValue(),
7178+
options: _this.props.options
71817179
}, _this.handleChange = function (event) {
71827180
var value = event.target.value;
71837181

build/react-dat-gui.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class App extends Component {
1919
minMaxNumber: 66,
2020
number: 80,
2121
boolean: true,
22-
select: 'one',
22+
select: 'three',
2323
color: '#2FA1D6',
2424
random: Math.random(),
2525
nested: {

dev/src/react-dat-gui/components/DatSelect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default class DatSelect extends Component {
1717
};
1818

1919
state = {
20-
value: '',
21-
options: [this.getValue(), ...this.props.options],
20+
value: this.getValue(),
21+
options: this.props.options,
2222
}
2323

2424
componentWillReceiveProps(nextProps) {

src/components/DatSelect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default class DatSelect extends Component {
1717
};
1818

1919
state = {
20-
value: '',
21-
options: [this.getValue(), ...this.props.options],
20+
value: this.getValue(),
21+
options: this.props.options,
2222
}
2323

2424
componentWillReceiveProps(nextProps) {

0 commit comments

Comments
 (0)