Skip to content
Snippets Groups Projects
Unverified Commit a4594fc0 authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub
Browse files

Merge pull request #2183 from sjhuang26/issue-2177-list-cycle

Change list wraparound logic when shift-tab pressed
parents a9bc7d59 77ca0518
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@ class ListMonitor extends React.Component {
else if (e.key === 'ArrowDown') navigateDirection = 1;
if (navigateDirection) {
this.handleDeactivate(); // Submit in-progress edits
const newIndex = (previouslyActiveIndex + navigateDirection) % this.props.value.length;
const newIndex = this.wrapListIndex(previouslyActiveIndex + navigateDirection, this.props.value.length);
this.setState({
activeIndex: newIndex,
activeValue: this.props.value[newIndex]
......@@ -87,7 +87,7 @@ class ListMonitor extends React.Component {
.concat([newListItemValue])
.concat(listValue.slice(previouslyActiveIndex + newValueOffset));
setVariableValue(vm, targetId, variableId, newListValue);
const newIndex = (previouslyActiveIndex + newValueOffset) % newListValue.length;
const newIndex = this.wrapListIndex(previouslyActiveIndex + newValueOffset, newListValue.length);
this.setState({
activeIndex: newIndex,
activeValue: newListItemValue
......@@ -144,6 +144,11 @@ class ListMonitor extends React.Component {
window.addEventListener('mouseup', onMouseUp);
}
wrapListIndex (index, length) {
return (index + length) % length;
}
render () {
const {
vm, // eslint-disable-line no-unused-vars
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment