Skip to content

Commit

Permalink
Fix: presentation viewer keyboard shortcuts (#754)
Browse files Browse the repository at this point in the history
DanDeMicco authored Mar 30, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent adc84e1 commit 9014bad
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/viewers/doc/PresentationViewer.js
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ class PresentationViewer extends DocBaseViewer {
* @param {string} key - Keydown key
* @return {boolean} Consumed or not
*/
onKeydown(key) {
onKeydown(key, event) {
if (key === 'ArrowUp') {
this.previousPage();
return true;
@@ -94,7 +94,7 @@ class PresentationViewer extends DocBaseViewer {
return true;
}

return super.onKeydown(key);
return super.onKeydown(key, event);
}

/**
8 changes: 7 additions & 1 deletion src/lib/viewers/doc/__tests__/PresentationViewer-test.js
Original file line number Diff line number Diff line change
@@ -177,8 +177,14 @@ describe('lib/viewers/doc/PresentationViewer', () => {
});

it('should fallback to doc base\'s onKeydown if no entry matches', () => {
const result = presentation.onKeydown('ArrowRight');
const docBaseSpy = sandbox.spy(DocBaseViewer.prototype, 'onKeydown');
const eventStub = sandbox.stub();

const key = 'ArrowRight';

const result = presentation.onKeydown(key, eventStub);

expect(docBaseSpy).to.have.been.calledWithExactly(key, eventStub);
expect(result).to.be.true;
expect(stubs.nextPage).to.be.called;

0 comments on commit 9014bad

Please sign in to comment.