Added handling of keyboard focus to UserSettingsModal and its children

Этот коммит содержится в:
hmhealey
2015-10-30 17:26:39 -04:00
родитель e56d21a920
Коммит 02b9414e0f
5 изменённых файлов: 51 добавлений и 12 удалений

Просмотреть файл

@@ -20,7 +20,6 @@ export default class ConfirmModal extends React.Component {
className='modal-confirm' className='modal-confirm'
show={this.props.show} show={this.props.show}
onHide={this.props.onCancel} onHide={this.props.onCancel}
enforceFocus={false}
> >
<Modal.Header closeButton={false}> <Modal.Header closeButton={false}>
<Modal.Title>{this.props.title}</Modal.Title> <Modal.Title>{this.props.title}</Modal.Title>

Просмотреть файл

@@ -56,6 +56,7 @@ export default class UserSettings extends React.Component {
activeSection={this.props.activeSection} activeSection={this.props.activeSection}
updateSection={this.props.updateSection} updateSection={this.props.updateSection}
updateTab={this.props.updateTab} updateTab={this.props.updateTab}
setEnforceFocus={this.props.setEnforceFocus}
/> />
</div> </div>
); );
@@ -77,6 +78,7 @@ export default class UserSettings extends React.Component {
activeSection={this.props.activeSection} activeSection={this.props.activeSection}
updateSection={this.props.updateSection} updateSection={this.props.updateSection}
updateTab={this.props.updateTab} updateTab={this.props.updateTab}
setEnforceFocus={this.props.setEnforceFocus}
setRequireConfirm={this.props.setRequireConfirm} setRequireConfirm={this.props.setRequireConfirm}
/> />
</div> </div>
@@ -134,5 +136,6 @@ UserSettings.propTypes = {
activeSection: React.PropTypes.string, activeSection: React.PropTypes.string,
updateSection: React.PropTypes.func, updateSection: React.PropTypes.func,
updateTab: React.PropTypes.func, updateTab: React.PropTypes.func,
setEnforceFocus: React.PropTypes.func.isRequired,
setRequireConfirm: React.PropTypes.func.isRequired setRequireConfirm: React.PropTypes.func.isRequired
}; };

Просмотреть файл

@@ -72,6 +72,8 @@ export default class UserSettingsAppearance extends React.Component {
if (!Utils.areStatesEqual(this.state, newState)) { if (!Utils.areStatesEqual(this.state, newState)) {
this.setState(newState); this.setState(newState);
} }
this.props.setEnforceFocus(true);
} }
submitTheme(e) { submitTheme(e) {
e.preventDefault(); e.preventDefault();
@@ -138,6 +140,8 @@ export default class UserSettingsAppearance extends React.Component {
type: ActionTypes.TOGGLE_IMPORT_THEME_MODAL, type: ActionTypes.TOGGLE_IMPORT_THEME_MODAL,
value: true value: true
}); });
this.props.setEnforceFocus(false);
} }
render() { render() {
var serverError; var serverError;
@@ -258,5 +262,6 @@ UserSettingsAppearance.defaultProps = {
UserSettingsAppearance.propTypes = { UserSettingsAppearance.propTypes = {
activeSection: React.PropTypes.string, activeSection: React.PropTypes.string,
updateTab: React.PropTypes.func, updateTab: React.PropTypes.func,
setRequireConfirm: React.PropTypes.func.isRequired setRequireConfirm: React.PropTypes.func.isRequired,
setEnforceFocus: React.PropTypes.func.isRequired
}; };

Просмотреть файл

@@ -13,6 +13,7 @@ export default class UserSettingsModal extends React.Component {
this.handleHide = this.handleHide.bind(this); this.handleHide = this.handleHide.bind(this);
this.handleHidden = this.handleHidden.bind(this); this.handleHidden = this.handleHidden.bind(this);
this.handleConfirm = this.handleConfirm.bind(this); this.handleConfirm = this.handleConfirm.bind(this);
this.handleCancelConfirmation = this.handleCancelConfirmation.bind(this);
this.updateTab = this.updateTab.bind(this); this.updateTab = this.updateTab.bind(this);
this.updateSection = this.updateSection.bind(this); this.updateSection = this.updateSection.bind(this);
@@ -20,7 +21,8 @@ export default class UserSettingsModal extends React.Component {
this.state = { this.state = {
active_tab: 'general', active_tab: 'general',
active_section: '', active_section: '',
showConfirmModal: false showConfirmModal: false,
enforceFocus: true
}; };
this.requireConfirm = false; this.requireConfirm = false;
@@ -78,7 +80,8 @@ export default class UserSettingsModal extends React.Component {
handleConfirm() { handleConfirm() {
this.setState({ this.setState({
showConfirmModal: false showConfirmModal: false,
enforceFocus: true
}); });
this.requireConfirm = false; this.requireConfirm = false;
@@ -89,9 +92,17 @@ export default class UserSettingsModal extends React.Component {
} }
} }
handleCancelConfirmation() {
this.setState({
showConfirmModal: false,
enforceFocus: true
});
}
showConfirmModal() { showConfirmModal() {
this.setState({ this.setState({
showConfirmModal: true showConfirmModal: true,
enforceFocus: false
}); });
} }
@@ -136,8 +147,9 @@ export default class UserSettingsModal extends React.Component {
<Modal <Modal
dialogClassName='settings-modal' dialogClassName='settings-modal'
show={this.props.show} show={this.props.show}
onHide={() => this.handleHide()} onHide={this.handleHide}
onExited={this.handleHidden} onExited={this.handleHidden}
enforceFocus={this.state.enforceFocus}
> >
<Modal.Header closeButton={true}> <Modal.Header closeButton={true}>
<Modal.Title>{'Account Settings'}</Modal.Title> <Modal.Title>{'Account Settings'}</Modal.Title>
@@ -158,6 +170,7 @@ export default class UserSettingsModal extends React.Component {
activeSection={this.state.active_section} activeSection={this.state.active_section}
updateSection={this.updateSection} updateSection={this.updateSection}
updateTab={this.updateTab} updateTab={this.updateTab}
setEnforceFocus={(enforceFocus) => this.setState({enforceFocus})}
setRequireConfirm={(requireConfirm) => this.requireConfirm = requireConfirm} setRequireConfirm={(requireConfirm) => this.requireConfirm = requireConfirm}
/> />
</div> </div>
@@ -169,7 +182,7 @@ export default class UserSettingsModal extends React.Component {
confirm_button='Yes, Discard' confirm_button='Yes, Discard'
show={this.state.showConfirmModal} show={this.state.showConfirmModal}
onConfirm={this.handleConfirm} onConfirm={this.handleConfirm}
onCancel={() => this.setState({showConfirmModal: false})} onCancel={this.handleCancelConfirmation}
/> />
</Modal> </Modal>
); );

Просмотреть файл

@@ -13,6 +13,9 @@ export default class SecurityTab extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.showAccessHistoryModal = this.showAccessHistoryModal.bind(this);
this.showActivityLogModal = this.showActivityLogModal.bind(this);
this.hideModals = this.hideModals.bind(this);
this.submitPassword = this.submitPassword.bind(this); this.submitPassword = this.submitPassword.bind(this);
this.updateCurrentPassword = this.updateCurrentPassword.bind(this); this.updateCurrentPassword = this.updateCurrentPassword.bind(this);
this.updateNewPassword = this.updateNewPassword.bind(this); this.updateNewPassword = this.updateNewPassword.bind(this);
@@ -24,6 +27,21 @@ export default class SecurityTab extends React.Component {
state.showActivityLogModal = false; state.showActivityLogModal = false;
this.state = state; this.state = state;
} }
showAccessHistoryModal() {
this.props.setEnforceFocus(false);
this.setState({showAccessHistoryModal: true});
}
showActivityLogModal() {
this.props.setEnforceFocus(false);
this.setState({showActivityLogModal: true});
}
hideModals() {
this.props.setEnforceFocus(true);
this.setState({
showAccessHistoryModal: false,
showActivityLogModal: false
});
}
submitPassword(e) { submitPassword(e) {
e.preventDefault(); e.preventDefault();
@@ -238,7 +256,7 @@ export default class SecurityTab extends React.Component {
<a <a
className='security-links theme' className='security-links theme'
href='#' href='#'
onClick={() => this.setState({showAccessHistoryModal: true})} onClick={this.showAccessHistoryModal}
> >
<i className='fa fa-clock-o'></i>View Access History <i className='fa fa-clock-o'></i>View Access History
</a> </a>
@@ -246,18 +264,18 @@ export default class SecurityTab extends React.Component {
<a <a
className='security-links theme' className='security-links theme'
href='#' href='#'
onClick={() => this.setState({showActivityLogModal: true})} onClick={this.showActivityLogModal}
> >
<i className='fa fa-globe'></i>View and Logout of Active Sessions <i className='fa fa-globe'></i>View and Logout of Active Sessions
</a> </a>
</div> </div>
<AccessHistoryModal <AccessHistoryModal
show={this.state.showAccessHistoryModal} show={this.state.showAccessHistoryModal}
onModalDismissed={() => this.setState({showAccessHistoryModal: false})} onModalDismissed={this.hideModals}
/> />
<ActivityLogModal <ActivityLogModal
show={this.state.showActivityLogModal} show={this.state.showActivityLogModal}
onModalDismissed={() => this.setState({showActivityLogModal: false})} onModalDismissed={this.hideModals}
/> />
</div> </div>
); );
@@ -272,5 +290,6 @@ SecurityTab.propTypes = {
user: React.PropTypes.object, user: React.PropTypes.object,
activeSection: React.PropTypes.string, activeSection: React.PropTypes.string,
updateSection: React.PropTypes.func, updateSection: React.PropTypes.func,
updateTab: React.PropTypes.func updateTab: React.PropTypes.func,
setEnforceFocus: React.PropTypes.func.isRequired
}; };