From 1bb01ab8eba6e4c777f500eb47345fb87ffe9514 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Fri, 18 Jan 2019 16:33:02 -0500 Subject: [PATCH] Allowing Privacy Policy link click to happen with modifier key --- src/components/Header/index.js | 4 ++++ src/components/Header/test.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/components/Header/index.js b/src/components/Header/index.js index f6d2a4a..3dadb70 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -26,6 +26,10 @@ class Header extends React.PureComponent { } handleOpen = event => { + if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) { + return; + } + event.preventDefault(); this.setState({ showModal: true }); } diff --git a/src/components/Header/test.js b/src/components/Header/test.js index 75cac6a..b371e36 100644 --- a/src/components/Header/test.js +++ b/src/components/Header/test.js @@ -30,6 +30,20 @@ describe('Header', () => { expect(component).toMatchSnapshot(); }); + ['shift', 'ctrl', 'alt', 'meta'].forEach(key => { + test(`opening the Privacy Policy modal while holding ${ key } key`, () => { + const component = shallow( +
+ ); + const eventObj = { preventDefault: jest.fn() }; + + component.instance().handleOpen({ [key + 'Key']: true, ...eventObj }); + + expect(eventObj.preventDefault).not.toHaveBeenCalled(); + expect(component.state('showModal')).toEqual(false); + }); + }); + test('closing the Privacy Policy modal', () => { const component = shallow(