fix file actions accessibility

This commit is contained in:
btzr-io 2021-07-15 15:14:21 -05:00
parent 6354a77bf1
commit 7c8c43d3a7
6 changed files with 20 additions and 13 deletions

View file

@ -321,7 +321,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
{/* @if TARGET='app' */} {/* @if TARGET='app' */}
{claim && !isCollection && ( {claim && !isCollection && (
<div className="claim-preview__hover-actions"> <div className="claim-preview__hover-actions">
<FileDownloadLink uri={canonicalUrl} hideOpenButton hideDownloadStatus /> <FileDownloadLink focusable={false} uri={canonicalUrl} hideOpenButton hideDownloadStatus />
</div> </div>
)} )}
{/* @endif */} {/* @endif */}
@ -332,7 +332,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
)} )}
{isPlayable && ( {isPlayable && (
<div className="claim-preview__hover-actions"> <div className="claim-preview__hover-actions">
<FileWatchLaterLink uri={uri} /> <FileWatchLaterLink focusable={false} uri={uri} />
</div> </div>
)} )}
</FileThumbnail> </FileThumbnail>

View file

@ -200,14 +200,14 @@ function ClaimPreviewTile(props: Props) {
{/* @if TARGET='app' */} {/* @if TARGET='app' */}
{isStream && ( {isStream && (
<div className="claim-preview__hover-actions"> <div className="claim-preview__hover-actions">
<FileDownloadLink uri={canonicalUrl} hideOpenButton /> <FileDownloadLink focusable={false} uri={canonicalUrl} hideOpenButton />
</div> </div>
)} )}
{/* @endif */} {/* @endif */}
{isPlayable && ( {isPlayable && (
<div className="claim-preview__hover-actions"> <div className="claim-preview__hover-actions">
<FileWatchLaterLink uri={uri} /> <FileWatchLaterLink focusable={false} uri={uri} />
</div> </div>
)} )}

View file

@ -117,7 +117,6 @@ function FileActions(props: Props) {
<ClaimSupportButton uri={uri} fileAction /> <ClaimSupportButton uri={uri} fileAction />
<ClaimCollectionAddButton uri={uri} fileAction /> <ClaimCollectionAddButton uri={uri} fileAction />
<Button <Button
button="alt"
className="button--file-action" className="button--file-action"
icon={ICONS.REPOST} icon={ICONS.REPOST}
label={ label={

View file

@ -11,6 +11,7 @@ type Props = {
claimIsMine: boolean, claimIsMine: boolean,
downloading: boolean, downloading: boolean,
loading: boolean, loading: boolean,
focusable: boolean,
fileInfo: ?FileListItem, fileInfo: ?FileListItem,
openModal: (id: string, { path: string }) => void, openModal: (id: string, { path: string }) => void,
pause: () => void, pause: () => void,
@ -35,6 +36,7 @@ function FileDownloadLink(props: Props) {
uri, uri,
claim, claim,
buttonType, buttonType,
focusable = true,
showLabel = false, showLabel = false,
hideOpenButton = false, hideOpenButton = false,
hideDownloadStatus = false, hideDownloadStatus = false,
@ -91,6 +93,8 @@ function FileDownloadLink(props: Props) {
pause(); pause();
openModal(MODALS.CONFIRM_EXTERNAL_RESOURCE, { path: fileInfo.download_path, isMine: claimIsMine }); openModal(MODALS.CONFIRM_EXTERNAL_RESOURCE, { path: fileInfo.download_path, isMine: claimIsMine });
}} }}
aria-hidden={!focusable}
tabIndex={focusable ? 0 : -1}
/> />
); );
} }
@ -105,6 +109,8 @@ function FileDownloadLink(props: Props) {
icon={ICONS.DOWNLOAD} icon={ICONS.DOWNLOAD}
label={showLabel ? label : null} label={showLabel ? label : null}
onClick={handleDownload} onClick={handleDownload}
aria-hidden={!focusable}
tabIndex={focusable ? 0 : -1}
/> />
); );
} }

View file

@ -8,18 +8,14 @@ import { COLLECTIONS_CONSTS } from 'lbry-redux';
type Props = { type Props = {
uri: string, uri: string,
claim: StreamClaim, claim: StreamClaim,
focusable: boolean,
hasClaimInWatchLater: boolean, hasClaimInWatchLater: boolean,
doToast: ({ message: string }) => void, doToast: ({ message: string }) => void,
doCollectionEdit: (string, any) => void, doCollectionEdit: (string, any) => void,
}; };
function FileWatchLaterLink(props: Props) { function FileWatchLaterLink(props: Props) {
const { const { claim, hasClaimInWatchLater, doToast, doCollectionEdit, focusable = true } = props;
claim,
hasClaimInWatchLater,
doToast,
doCollectionEdit,
} = props;
const buttonRef = useRef(); const buttonRef = useRef();
let isHovering = useHover(buttonRef); let isHovering = useHover(buttonRef);
@ -53,8 +49,13 @@ function FileWatchLaterLink(props: Props) {
title={title} title={title}
label={label} label={label}
className="button--file-action" className="button--file-action"
icon={(hasClaimInWatchLater && (isHovering ? ICONS.REMOVE : ICONS.COMPLETED)) || (isHovering ? ICONS.COMPLETED : ICONS.TIME)} icon={
(hasClaimInWatchLater && (isHovering ? ICONS.REMOVE : ICONS.COMPLETED)) ||
(isHovering ? ICONS.COMPLETED : ICONS.TIME)
}
onClick={(e) => handleWatchLater(e)} onClick={(e) => handleWatchLater(e)}
aria-hidden={!focusable}
tabIndex={focusable ? 0 : -1}
/> />
); );
} }

View file

@ -17,7 +17,8 @@
width: 0; width: 0;
height: 0; height: 0;
overflow: hidden; overflow: hidden;
margin: 0 var(--spacing-s); margin-right: var(--spacing-l);
&:focus { &:focus {
opacity: 1; opacity: 1;
position: relative; position: relative;