Skip to content
Snippets Groups Projects
Unverified Commit 5dbbeae6 authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub
Browse files

Merge pull request #986 from quachtina96/libraryScreenReader

Make libraries screen reader accessible.
parents a9ec9fe8 652abb9f
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ const CloseButton = props => ( ...@@ -17,6 +17,7 @@ const CloseButton = props => (
} }
)} )}
role="button" role="button"
tabIndex="0"
onClick={props.onClick} onClick={props.onClick}
> >
<img <img
......
...@@ -10,15 +10,30 @@ class LibraryItem extends React.PureComponent { ...@@ -10,15 +10,30 @@ class LibraryItem extends React.PureComponent {
constructor (props) { constructor (props) {
super(props); super(props);
bindAll(this, [ bindAll(this, [
'handleBlur',
'handleClick', 'handleClick',
'handleFocus',
'handleKeyPress',
'handleMouseEnter', 'handleMouseEnter',
'handleMouseLeave' 'handleMouseLeave'
]); ]);
} }
handleBlur () {
this.props.onBlur(this.props.id);
}
handleFocus () {
this.props.onFocus(this.props.id);
}
handleClick (e) { handleClick (e) {
this.props.onSelect(this.props.id); this.props.onSelect(this.props.id);
e.preventDefault(); e.preventDefault();
} }
handleKeyPress (e) {
if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault();
this.props.onSelect(this.props.id);
}
}
handleMouseEnter () { handleMouseEnter () {
this.props.onMouseEnter(this.props.id); this.props.onMouseEnter(this.props.id);
} }
...@@ -48,7 +63,12 @@ class LibraryItem extends React.PureComponent { ...@@ -48,7 +63,12 @@ class LibraryItem extends React.PureComponent {
) : ( ) : (
<Box <Box
className={styles.libraryItem} className={styles.libraryItem}
role="button"
tabIndex="0"
onBlur={this.handleBlur}
onClick={this.handleClick} onClick={this.handleClick}
onFocus={this.handleFocus}
onKeyPress={this.handleKeyPress}
onMouseEnter={this.handleMouseEnter} onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave} onMouseLeave={this.handleMouseLeave}
> >
...@@ -73,6 +93,8 @@ LibraryItem.propTypes = { ...@@ -73,6 +93,8 @@ LibraryItem.propTypes = {
iconURL: PropTypes.string.isRequired, iconURL: PropTypes.string.isRequired,
id: PropTypes.number.isRequired, id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onFocus: PropTypes.func,
onMouseEnter: PropTypes.func.isRequired, onMouseEnter: PropTypes.func.isRequired,
onMouseLeave: PropTypes.func.isRequired, onMouseLeave: PropTypes.func.isRequired,
onSelect: PropTypes.func.isRequired onSelect: PropTypes.func.isRequired
......
...@@ -11,8 +11,10 @@ class LibraryComponent extends React.Component { ...@@ -11,8 +11,10 @@ class LibraryComponent extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
bindAll(this, [ bindAll(this, [
'handleBlur',
'handleFilterChange', 'handleFilterChange',
'handleFilterClear', 'handleFilterClear',
'handleFocus',
'handleMouseEnter', 'handleMouseEnter',
'handleMouseLeave', 'handleMouseLeave',
'handleSelect' 'handleSelect'
...@@ -22,6 +24,12 @@ class LibraryComponent extends React.Component { ...@@ -22,6 +24,12 @@ class LibraryComponent extends React.Component {
filterQuery: '' filterQuery: ''
}; };
} }
handleBlur (id) {
this.handleMouseLeave(id);
}
handleFocus (id) {
this.handleMouseEnter(id);
}
handleSelect (id) { handleSelect (id) {
this.props.onRequestClose(); this.props.onRequestClose();
this.props.onItemSelected(this.getFilteredData()[id]); this.props.onItemSelected(this.getFilteredData()[id]);
...@@ -65,6 +73,8 @@ class LibraryComponent extends React.Component { ...@@ -65,6 +73,8 @@ class LibraryComponent extends React.Component {
id={index} id={index}
key={`item_${index}`} key={`item_${index}`}
name={dataItem.name} name={dataItem.name}
onBlur={this.handleBlur}
onFocus={this.handleFocus}
onMouseEnter={this.handleMouseEnter} onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave} onMouseLeave={this.handleMouseLeave}
onSelect={this.handleSelect} onSelect={this.handleSelect}
......
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import Modal from 'react-modal';
import AppStateHOC from './lib/app-state-hoc.jsx'; import AppStateHOC from './lib/app-state-hoc.jsx';
import GUI from './containers/gui.jsx'; import GUI from './containers/gui.jsx';
...@@ -18,4 +19,6 @@ const appTarget = document.createElement('div'); ...@@ -18,4 +19,6 @@ const appTarget = document.createElement('div');
appTarget.className = styles.app; appTarget.className = styles.app;
document.body.appendChild(appTarget); document.body.appendChild(appTarget);
Modal.setAppElement(appTarget);
ReactDOM.render(<App />, appTarget); ReactDOM.render(<App />, appTarget);
...@@ -16,6 +16,7 @@ exports[`SpriteSelectorItemComponent matches snapshot when selected 1`] = ` ...@@ -16,6 +16,7 @@ exports[`SpriteSelectorItemComponent matches snapshot when selected 1`] = `
className="" className=""
onClick={[Function]} onClick={[Function]}
role="button" role="button"
tabIndex="0"
> >
<img <img
className={undefined} className={undefined}
......
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