Skip to content

Commit

Permalink
Merge pull request #359 from samvera-labs/hotkeys-fix
Browse files Browse the repository at this point in the history
Fix breaking hotkeys after switching Canvas
  • Loading branch information
Dananji authored Jan 25, 2024
2 parents 0d5ab15 + 756924b commit 341af2b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/services/utility-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ export function fileDownload(fileUrl, fileName, fileExt = '', machineGenerated =

// If no extension present in fileName, check for the extension in the fileUrl
if (extension.length > 4 || extension.length < 3) {
extension = fileUrl.split('.').reverse()[0]
extension = fileUrl.split('.').reverse()[0];
} else {
extension
extension;
}

// If unhandled file type use .doc
Expand Down Expand Up @@ -490,13 +490,16 @@ export function autoScroll(currentItem, containerRef) {
? scrollHeight - containerRef.current.clientHeight / 2 : 0;
};

export function playerHotKeys(event, playerInst) {
export function playerHotKeys(event, player) {
let playerInst = player?.player_;
var inputs = ['input', 'textarea'];
var activeElement = document.activeElement;

/** Trigger player hotkeys when focus is not on an input, textarea, or navigation tab */
if (activeElement && (inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1 || activeElement.role === "tab")) {
return;
} else if (playerInst === null || playerInst === undefined) {
return;
} else {
var pressedKey = event.which;
// event.which key code values found at: https://css-tricks.com/snippets/javascript/javascript-keycodes/
Expand Down

0 comments on commit 341af2b

Please sign in to comment.