Skip to content

Commit

Permalink
Støtte for onBlur i dropdown react komponent
Browse files Browse the repository at this point in the history
  • Loading branch information
gjomoe committed Sep 26, 2016
1 parent 22f8336 commit 984a42b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.3.0

* Added onBlur support

## 2.2.0

* Relaxing the peer dependency on `ffe-form` to allow both 1.x and 2.x
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffe-dropdown-react",
"version": "2.2.0",
"version": "2.3.0",
"main": "lib/dropdown.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/. && npm run example",
Expand Down
3 changes: 3 additions & 0 deletions src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Dropdown({
className = '',
label,
onChange,
onBlur,
selectedValue,
defaultValue,
children,
Expand All @@ -31,6 +32,7 @@ function Dropdown({
className={`ffe-dropdown ${className}`}
id={ domId }
onChange={ onChange }
onBlur={ onBlur }
value={ selectedValue }
defaultValue={ defaultValue }
aria-invalid={ invalid }
Expand All @@ -54,6 +56,7 @@ Dropdown.propTypes = {
id: PropTypes.string,
label: PropTypes.string,
onChange: PropTypes.func.isRequired,
onBlur: PropTypes.func,
selectedValue: PropTypes.string,
defaultValue: PropTypes.string,
children: PropTypes.array,
Expand Down
7 changes: 7 additions & 0 deletions src/dropdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ describe('<Dropdown />', () => {
assert.equal(spy.calledOnce, true);
});

it('should call the passed function on blur', () => {
const spy = sinon.spy();
const wrapper = shallow(createDropdown({ onBlur: spy }));
wrapper.find('select').simulate('blur');
assert.equal(spy.calledOnce, true);
});

it('should apply the same id to <label> and <select>', () => {
const wrapper = shallow(Example);

Expand Down

0 comments on commit 984a42b

Please sign in to comment.