Skip to content

Commit

Permalink
[E] Improve focus on page change
Browse files Browse the repository at this point in the history
  • Loading branch information
1aurend committed May 20, 2024
1 parent 890d720 commit 91dc203
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
5 changes: 4 additions & 1 deletion client/src/reader/components/section/NextSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ class NextSection extends PureComponent {
if (!nextSection || !nextSection.name) return null;
return (
<Link
to={this.getSectionPath(nextSection.id)}
to={{
pathname: this.getSectionPath(nextSection.id),
state: { pageChange: true }
}}
className="section-next-section__link"
>
<header className="section-next-section__header">
Expand Down
22 changes: 9 additions & 13 deletions client/src/reader/components/section/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ export default class Text extends Component {
}

componentDidMount() {
if (this.el && this.props.location.state?.pageChange) {
this.el.focus();
const el = document.getElementById("text-section-interactive-region");

if (el && this.props.location.state?.pageChange) {
el.focus();
}
}

componentDidUpdate() {
this.checkRequestAnnotationHash();

if (this.el && this.props.location.state?.pageChange) {
this.el.focus();
const el = document.getElementById("text-section-interactive-region");

if (el && this.props.location.state?.pageChange) {
el.focus();
}
}

Expand Down Expand Up @@ -128,15 +132,7 @@ export default class Text extends Component {

return (
<HtmlClass className={fontSizeClass}>
<div
id="focus-on-page-change"
ref={el => {
this.el = el;
}}
tabIndex={-1}
className="main-content"
style={{ flexGrow: 1 }}
>
<div className="main-content" style={{ flexGrow: 1 }}>
<section className={readerAppearanceClass}>
<Annotation.Annotatable
currentUser={this.props.authentication.currentUser}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class AnnotatableCaptureSelection extends Component {
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-noninteractive-tabindex */
return (
<div
id="text-section-interactive-region"
ref={this.props.setSelectableRef}
role="region"
aria-label={this.props.t("reader.section_label")}
Expand Down

0 comments on commit 91dc203

Please sign in to comment.