Skip to content

MSFT-187 #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"filestack-js": "^1.7.7",
"filestack-react": "^2.0.0",
"flag-icon-css": "^3.3.0",
"focus-trap-react": "^6.0.0",
"helmet": "^3.12.1",
"highlight.js": "^9.13.1",
"html-to-text": "^3.3.0",
Expand Down
28 changes: 20 additions & 8 deletions src/shared/components/Terms/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
/**
* Terms component which displays modal window with term details
*/
Expand All @@ -9,6 +10,7 @@ import React from 'react';
import PT from 'prop-types';
import { Modal, PrimaryButton, Button } from 'topcoder-react-ui-kit';
import LoadingIndicator from 'components/LoadingIndicator';
import FocusTrap from 'focus-trap-react';
import TermDetails from './TermDetails';

import style from './styles.scss';
Expand Down Expand Up @@ -54,6 +56,7 @@ export default class Terms extends React.Component {
this.resizeHandler = this.resizeHandler.bind(this);
this.nextTerm = this.nextTerm.bind(this);
this.max = 0;
this.terms = React.createRef();
}

componentDidMount() {
Expand All @@ -63,6 +66,7 @@ export default class Terms extends React.Component {
}
window.addEventListener('message', this.messageHandler, false);
window.addEventListener('resize', this.resizeHandler, false);
this.terms.current.focus();
}

componentWillReceiveProps(nextProps) {
Expand All @@ -83,6 +87,10 @@ export default class Terms extends React.Component {
}
}

componentDidUpdate() {
this.terms.current.focus();
}

componentWillUnmount() {
window.removeEventListener('message', this.messageHandler);
window.removeEventListener('resize', this.resizeHandler);
Expand Down Expand Up @@ -152,17 +160,18 @@ export default class Terms extends React.Component {

return (
<div key={(selectedTerm || {}).termsOfUseId}>
<Modal
onCancel={onCancel}
theme={{ container: style['modal-container'] }}
>
{
<FocusTrap>
<Modal
onCancel={onCancel}
theme={{ container: style['modal-container'] }}
>
{
isLoadingTerms
&& <LoadingIndicator />
}
{
{
!isLoadingTerms && (
<div styleName="modal-content">
<div styleName="modal-content" ref={this.terms} tabIndex="0">
<div styleName="title">
{terms.length > 1 ? defaultTitle : terms[0].title}
</div>
Expand Down Expand Up @@ -216,6 +225,8 @@ export default class Terms extends React.Component {
</div>
<div
styleName="tab-title"
tabIndex="0"
role="tab"
onClick={() => this.selectTerm(t)}
onKeyPress={() => this.selectTerm(t)}
>
Expand Down Expand Up @@ -318,7 +329,8 @@ export default class Terms extends React.Component {
</div>
)
}
</Modal>
</Modal>
</FocusTrap>
</div>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/shared/components/Terms/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
flex: 1;
flex-direction: column;
max-height: 100%;

&:focus {
outline: none;
}
}

.scrollable-area {
Expand Down