Socket
Socket
Sign inDemoInstall

cpr-select

Package Overview
Dependencies
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpr-select - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

20

lib/select.js

@@ -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});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc