Skip to content

Commit

Permalink
Fix unable to copy to clipboard with keyboard #251
Browse files Browse the repository at this point in the history
  • Loading branch information
tnajdek committed Aug 7, 2021
1 parent 73da30a commit dc464f2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/js/components/export-tools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { saveAs } from 'file-saver';

import exportFormats from '../constants/export-formats';
import Button from './ui/button';
import { isTriggerEvent } from '../common/event';

const formatsInDropdown = ['rtf', 'html', 'ris', 'bibtex', 'zotero'];

Expand Down Expand Up @@ -93,6 +94,10 @@ const ExportTools = props => {
}, [isDropdownOpen]);

const handleCopyClick = useCallback(async ev => {
if(!isTriggerEvent(ev)) {
return;
}

const format = ev.currentTarget.dataset.format;
const isTopLevelButton = 'main' in ev.currentTarget.dataset;
if(isTopLevelButton) {
Expand Down Expand Up @@ -120,6 +125,7 @@ const ExportTools = props => {
disabled={ bibliography.items.length === 0 }
className='btn btn-secondary btn-xl copy-to-clipboard'
onClick={ handleCopyClick }
onKeyDown={ handleCopyClick }
>
<span className={ cx('inline-feedback', { 'active': isCopied }) }>
<span className="default-text" aria-hidden={ !isCopied }>{ exportFormats['plain'].label }</span>
Expand Down

0 comments on commit dc464f2

Please sign in to comment.