);
@@ -107,6 +120,7 @@ export default class Portal extends Component {
}
handleKeyDown = (event) => {
+ const { onKeyDown } = this.props;
const codeName = keycode(event);
switch (codeName) {
@@ -116,12 +130,16 @@ export default class Portal extends Component {
default:
event.persist();
- return this.props.onKeyDown(event);
+ return onKeyDown
+ ? onKeyDown(event)
+ : false;
}
}
handleDOMAction = (ref, method) => {
- const refItem = typeof ref === 'string' ? this.refs[ref] : ref;
+ const refItem = typeof ref === 'string'
+ ? this.refs[ref]
+ : ref;
const element = ReactDOM.findDOMNode(refItem);
if (!element || typeof element[method] !== 'function') {
diff --git a/js/src/ui/Portal/portal.spec.js b/js/src/ui/Portal/portal.spec.js
new file mode 100644
index 00000000000..6d2f5d5f384
--- /dev/null
+++ b/js/src/ui/Portal/portal.spec.js
@@ -0,0 +1,47 @@
+// Copyright 2015-2017 Parity Technologies (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity. If not, see .
+
+import { shallow } from 'enzyme';
+import React from 'react';
+import sinon from 'sinon';
+
+import Portal from './';
+
+let component;
+let onClose;
+
+function render (props = {}) {
+ onClose = sinon.stub();
+ component = shallow(
+
+ );
+
+ return component;
+}
+
+describe('ui/Portal', () => {
+ beforeEach(() => {
+ render();
+ });
+
+ it('renders defaults', () => {
+ expect(component).to.be.ok;
+ });
+});
diff --git a/js/src/ui/index.js b/js/src/ui/index.js
index 99a6348af2d..37dc88e9a39 100644
--- a/js/src/ui/index.js
+++ b/js/src/ui/index.js
@@ -47,6 +47,7 @@ import muiTheme from './Theme';
import Page from './Page';
import ParityBackground from './ParityBackground';
import PasswordStrength from './Form/PasswordStrength';
+import Portal from './Portal';
import QrCode from './QrCode';
import SectionList from './SectionList';
import ShortenedHash from './ShortenedHash';
@@ -103,6 +104,7 @@ export {
Page,
ParityBackground,
PasswordStrength,
+ Portal,
QrCode,
RadioButtons,
Select,