Skip to content

Commit 1d2b4db

Browse files
committed
Re-enable index-based keys for options
Reverses backwards-compatibility-breaking changes introduced in cccb705.
1 parent d640653 commit 1d2b4db

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

examples/dist/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21884,18 +21884,22 @@ return /******/ (function(modules) { // webpackBootstrap
2188421884
value: function renderOptions(options) {
2188521885
var _this7 = this;
2188621886

21887-
return options.map(function (option) {
21887+
return options.map(function (option, index) {
21888+
// Intentionally use array index to allow React to jump to next selection
21889+
// https://github.com/jakezatecky/react-dual-listbox/issues/10
21890+
var key = 'key-' + index;
21891+
2188821892
if (option.options !== undefined) {
2188921893
return _react2.default.createElement(
2189021894
'optgroup',
21891-
{ key: option.label, label: option.label },
21895+
{ key: key, label: option.label },
2189221896
_this7.renderOptions(option.options)
2189321897
);
2189421898
}
2189521899

2189621900
return _react2.default.createElement(
2189721901
'option',
21898-
{ key: option.value, value: option.value },
21902+
{ key: key, value: option.value },
2189921903
option.label
2190021904
);
2190121905
});

src/js/DualListBox.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,21 @@ class DualListBox extends React.Component {
268268
* @returns {Array}
269269
*/
270270
renderOptions(options) {
271-
return options.map((option) => {
271+
return options.map((option, index) => {
272+
// Intentionally use array index to allow React to jump to next selection
273+
// https://github.com/jakezatecky/react-dual-listbox/issues/10
274+
const key = `key-${index}`;
275+
272276
if (option.options !== undefined) {
273277
return (
274-
<optgroup key={option.label} label={option.label}>
278+
<optgroup key={key} label={option.label}>
275279
{this.renderOptions(option.options)}
276280
</optgroup>
277281
);
278282
}
279283

280284
return (
281-
<option key={option.value} value={option.value}>
285+
<option key={key} value={option.value}>
282286
{option.label}
283287
</option>
284288
);

0 commit comments

Comments
 (0)