Skip to content
Snippets Groups Projects
Commit 57a79854 authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

Merge branch 'autofocus_student_matching' into 'master'

Autofocus student matching

See merge request zesje/zesje!114
parents 07d0acf3 d6520d2c
No related branches found
No related tags found
No related merge requests found
......@@ -27,10 +27,10 @@ build:
- zesje/static
expire_in: 1 week
# test_js:
# <<: *node_modules
# stage: test
# script: yarn test:js
test_js:
<<: *node_modules
stage: test
script: yarn test:js
test_py:
stage: test
......
import React from 'react'
import ReactDOM from 'react-dom'
import Notification from 'react-bulma-notification'
import Fuse from 'fuse.js'
......@@ -36,6 +37,10 @@ class SearchPanel extends React.Component {
})
}
componentDidUpdate (prevProps, prevState) {
ReactDOM.findDOMNode(this).getElementById('panel-input').focus()
}
search = (event) => {
const options = {
shouldSort: true,
......@@ -113,7 +118,7 @@ class SearchPanel extends React.Component {
</p>
<div className='panel-block'>
<p className='control has-icons-left'>
<input className='input' type='text'
<input id='panel-input' className='input' type='text' autoFocus
value={this.state.input} onChange={this.search} onKeyDown={this.specialKey} />
<span className='icon is-left'>
......
/* eslint-env jest */
import React from 'react'
import {mount} from 'enzyme'
import SearchPanel from '../SearchPanel'
test('Student id searchfield has focus on loading component', () => {
mount(<SearchPanel />)
const focusedElem = document.activeElement
expect(focusedElem.id).toEqual('panel-input')
})
module.exports = {
'moduleNameMapper': {
'\\.(css|md)$': 'identity-obj-proxy'
}
},
'testPathIgnorePatterns': ['/node_modules/', '/.yarn-cache/'],
'modulePathIgnorePatterns': ['.yarn-cache'],
'setupTestFrameworkScriptFile': '<rootDir>testSetup.js'
}
// setup file
var enzyme = require('enzyme')
var Adapter = require('enzyme-adapter-react-16')
enzyme.configure({ adapter: new Adapter() })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment