Allowing Privacy Policy link click to happen with modifier key
This commit is contained in:
		
							parent
							
								
									2c8b779793
								
							
						
					
					
						commit
						1bb01ab8eb
					
				| @ -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 }); | ||||
|   } | ||||
|  | ||||
| @ -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( | ||||
|         <Header banner={ false } /> | ||||
|       ); | ||||
|       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( | ||||
|       <Header banner={ false } /> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user