cpr-select
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -55,8 +55,2 @@ 'use strict'; | ||
var selectedIndex = null; | ||
if (this.props.selected) { | ||
selectedIndex = this.getIndex(this.props.selected); | ||
} | ||
return { | ||
@@ -102,6 +96,12 @@ dialogDisplayed: false, | ||
this.setState({ | ||
dialogDisplayed: true, | ||
selectedIndex: selectedIndex === undefined ? 0 : selectedIndex - 1 | ||
}); | ||
if (selectedIndex <= 0) { | ||
this.setState({ | ||
dialogDisplayed: true | ||
}); | ||
} else { | ||
this.setState({ | ||
dialogDisplayed: true, | ||
selectedIndex: selectedIndex === undefined ? 0 : selectedIndex - 1 | ||
}); | ||
} | ||
@@ -108,0 +108,0 @@ //positionDialog(scope.collection[scope.selectedIndex]); |
@@ -105,2 +105,33 @@ 'use strict'; | ||
}); | ||
it('Should not allow up arrow to go out of bounds', function (run) { | ||
var items = [{ | ||
"value": "Alabama", | ||
"key": "AL" | ||
}, { | ||
"value": "Alaska", | ||
"key": "AK" | ||
}, { | ||
"value": "American Samoa", | ||
"key": "AS" | ||
}]; | ||
function callback(key, item, index) { | ||
expect(key).toBe('AL'); | ||
expect(item.key).toBe('AL'); | ||
expect(index).toBe(0); | ||
run(); | ||
} | ||
var multiSelect = _reactLibReactTestUtils2['default'].renderIntoDocument(_react2['default'].createElement(_selectJs2['default'], { options: items, onChange: callback })); | ||
var select = _reactLibReactTestUtils2['default'].findRenderedDOMComponentWithClass(multiSelect, 'cp-select'); | ||
_reactLibReactTestUtils2['default'].Simulate.click(select); | ||
var input = _reactLibReactTestUtils2['default'].findRenderedDOMComponentWithClass(multiSelect, 'cp-select__hidden-input'); | ||
_reactLibReactTestUtils2['default'].Simulate.keyDown(input, { which: 38 }); | ||
_reactLibReactTestUtils2['default'].Simulate.keyDown(input, { which: 38 }); | ||
_reactLibReactTestUtils2['default'].Simulate.keyDown(input, { which: 38 }); | ||
_reactLibReactTestUtils2['default'].Simulate.keyDown(input, { which: 38 }); | ||
_reactLibReactTestUtils2['default'].Simulate.keyDown(input, { which: 13 }); | ||
}); | ||
}); |
{ | ||
"name": "cpr-select", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "A consistently styled cross-browser and keyboard friendly select component", | ||
@@ -5,0 +5,0 @@ "main": "lib/select.js", |
@@ -23,8 +23,2 @@ import React from 'react'; | ||
getInitialState: function() { | ||
let selectedIndex = null; | ||
if (this.props.selected) { | ||
selectedIndex = this.getIndex(this.props.selected); | ||
} | ||
return { | ||
@@ -67,6 +61,12 @@ dialogDisplayed: false, | ||
this.setState({ | ||
dialogDisplayed: true, | ||
selectedIndex: selectedIndex === undefined ? 0 : selectedIndex - 1 | ||
}); | ||
if (selectedIndex <= 0) { | ||
this.setState({ | ||
dialogDisplayed: true, | ||
}); | ||
} else { | ||
this.setState({ | ||
dialogDisplayed: true, | ||
selectedIndex: selectedIndex === undefined ? 0 : selectedIndex - 1 | ||
}); | ||
} | ||
@@ -73,0 +73,0 @@ //positionDialog(scope.collection[scope.selectedIndex]); |
@@ -110,2 +110,37 @@ import CanopySelect from './select.js'; | ||
}); | ||
it('Should not allow up arrow to go out of bounds', function(run) { | ||
let items = [ | ||
{ | ||
"value": "Alabama", | ||
"key": "AL" | ||
}, { | ||
"value": "Alaska", | ||
"key": "AK" | ||
}, { | ||
"value": "American Samoa", | ||
"key": "AS" | ||
} | ||
]; | ||
function callback(key, item, index) { | ||
expect(key).toBe('AL'); | ||
expect(item.key).toBe('AL'); | ||
expect(index).toBe(0); | ||
run(); | ||
} | ||
let multiSelect = TestUtils.renderIntoDocument( | ||
<CanopySelect options={items} onChange={callback}></CanopySelect> | ||
); | ||
let select = TestUtils.findRenderedDOMComponentWithClass(multiSelect, 'cp-select'); | ||
TestUtils.Simulate.click(select); | ||
let input = TestUtils.findRenderedDOMComponentWithClass(multiSelect, 'cp-select__hidden-input'); | ||
TestUtils.Simulate.keyDown(input, {which: 38}); | ||
TestUtils.Simulate.keyDown(input, {which: 38}); | ||
TestUtils.Simulate.keyDown(input, {which: 38}); | ||
TestUtils.Simulate.keyDown(input, {which: 38}); | ||
TestUtils.Simulate.keyDown(input, {which: 13}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
0
29314
9
833
2