Skip to content

Commit

Permalink
Fix: isPageNumFocused() null check (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyjin authored Sep 18, 2017
1 parent ba4f354 commit b7eb6dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
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;

This comment has been minimized.

Copy link
@jeremypress

jeremypress Sep 26, 2017

Contributor

@tonyjin here's the mobile zoom fix

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

0 comments on commit b7eb6dc

Please sign in to comment.