Skip to content
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

Fix: isPageNumFocused() null check #401

Merged
merged 2 commits into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/lib/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class Controls {
* @return {boolean} Is the input focused
*/
isPageNumFocused() {
return document.activeElement.classList.contains(CONTROLS_PAGE_NUM_INPUT_CLASS);
return document.activeElement && document.activeElement.classList.contains(CONTROLS_PAGE_NUM_INPUT_CLASS);
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/lib/__tests__/Controls-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,16 @@ describe('lib/Controls', () => {
expect(controls.controlsEl.classList.contains(CLASS_HIDDEN)).to.be.true;
});
});

describe('isPageNumFocused()', () => {
it('should return true if page num element is focused', () => {
document.activeElement.classList.add('bp-page-num-input');
expect(controls.isPageNumFocused()).to.be.true;
});

it('should return false if page num element is not', () => {
document.activeElement.classList.remove('bp-page-num-input');
expect(controls.isPageNumFocused()).to.be.false;
});
})
});
3 changes: 0 additions & 3 deletions src/lib/viewers/doc/_docBase.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@

//---------- Override CSS from generic PDFJS viewer build ----------//
.pdfViewer .page {
align-items: center;
border: 0;
border-image: none;
/* stylelint-disable declaration-no-important */
box-sizing: content-box !important;
/* stylelint-enable declaration-no-important */
display: flex;
justify-content: center;
margin: 0 auto;
// We use padding instead of margin to push down since we want to
// include this padding when PDF.js jumps to pages
Expand Down