Skip to content

Commit 5b0a219

Browse files
aquibmebrillhart
authored andcommitted
Fix slide navigation after coming out of overview mode (#606)
Fixes #559 by resetting viewed items when the user navigates to a slide using the overview feature.
1 parent 003c4e7 commit 5b0a219

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/components/__snapshots__/manager.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ exports[`<Manager /> should render the overview configuration when specified. 1`
581581
onTouchStart={[Function]}
582582
>
583583
<Overview
584+
resetViewedIndexes={[Function]}
584585
route={
585586
Object {
586587
"params": Array [

src/components/manager.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export class Manager extends Component {
157157
this._goToSlide = this._goToSlide.bind(this);
158158
this._startAutoplay = this._startAutoplay.bind(this);
159159
this._stopAutoplay = this._stopAutoplay.bind(this);
160+
this._resetViewedIndexes = this._resetViewedIndexes.bind(this);
160161
this.presentationConnection = null;
161162

162163
this.state = {
@@ -409,6 +410,11 @@ export class Manager extends Component {
409410
this.context.history.replace(`/${slide}${this._getSuffix()}`);
410411
}
411412
}
413+
414+
_resetViewedIndexes() {
415+
this.viewedIndexes = new Set();
416+
}
417+
412418
_prevSlide() {
413419
const slideIndex = this._getSlideIndex();
414420
this.setState({
@@ -490,7 +496,7 @@ export class Manager extends Component {
490496
) {
491497
const slideData = '{ "slide": "0", "forward": "false" }';
492498
this._goToSlide({ key: 'spectacle-slide', newValue: slideData });
493-
this.viewedIndexes = new Set();
499+
this._resetViewedIndexes();
494500
}
495501
} else if (slideIndex < slideReference.length - 1) {
496502
this.viewedIndexes.add(slideIndex);
@@ -813,6 +819,7 @@ export class Manager extends Component {
813819
slideReference={this.state.slideReference}
814820
slideIndex={this._getSlideIndex()}
815821
route={this.props.route}
822+
resetViewedIndexes={this._resetViewedIndexes}
816823
/>
817824
);
818825
} else {

src/components/overview.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default class Overview extends Component {
3939
window.removeEventListener('resize', this.resizeHandler);
4040
}
4141
_slideClicked(index) {
42+
this.props.resetViewedIndexes();
4243
this.context.history.replace(`/${this._getHash(index)}`);
4344
}
4445
_getHash(slideIndex) {
@@ -86,6 +87,7 @@ export default class Overview extends Component {
8687
}
8788

8889
Overview.propTypes = {
90+
resetViewedIndexes: PropTypes.function,
8991
route: PropTypes.object,
9092
slideIndex: PropTypes.number,
9193
slideReference: PropTypes.array,

0 commit comments

Comments
 (0)