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(esl-media): make video unfocusable if esl-media[role=presentation] #2829

Merged
merged 6 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/modules/esl-media/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ using a single tag as well as work with external providers using simple native-l

- `start-time` - attribute that allows a user to start viewing a video from a specific time offset. The value is simple time in seconds. By default, it is undefined which means to start from the beginning.
*(note: that feature doesn't work for Abstract Iframe provider, also doesn't work for HTMLAudio and HTMLVideo providers in case when Web-server when hosted resource doesn't support ['Accept-Ranges' HTTP response marker](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Ranges))*
- `focusable` (boolean) - marker that allows the video to be focused by keyboard navigation. By default, the video is focusable if `controls` are enabled.

#### Deprecated attributes (going to be removed in the next major release):
- `load-cls-accepted` (optional) - class to add when the media is loaded and accepted by the load condition. Use `load-condition-class` instead.
Expand Down
5 changes: 3 additions & 2 deletions src/modules/esl-media/core/esl-media-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface MediaProviderConfig {
preload?: 'none' | 'metadata' | 'auto' | '';
playsinline?: boolean;
startTime?: number;
focusable?: boolean;
}

export type ProviderType = (new(component: ESLMedia, config: MediaProviderConfig) => BaseProvider) & typeof BaseProvider;
Expand All @@ -40,8 +41,8 @@ export abstract class BaseProvider {
return null;
}
static parseConfig(component: ESLMedia): MediaProviderConfig {
const {loop, muted, controls, autoplay, title, preload, playsinline, mediaId, mediaSrc, startTime} = component;
const config = {loop, muted, controls, autoplay, title, preload, playsinline, startTime};
const {loop, muted, controls, autoplay, title, preload, playsinline, mediaId, mediaSrc, startTime, focusable} = component;
const config = {loop, muted, controls, autoplay, title, preload, playsinline, startTime, focusable};
if (mediaId) Object.assign(config, {mediaId});
if (mediaSrc) Object.assign(config, {mediaSrc});
return config;
Expand Down
5 changes: 4 additions & 1 deletion src/modules/esl-media/core/esl-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {SPACE, PAUSE} from '../../esl-utils/dom/keys';
import {prop, attr, boolAttr, listen} from '../../esl-utils/decorators';
import {debounce} from '../../esl-utils/async';
import {parseAspectRatio} from '../../esl-utils/misc/format';
import {parseAspectRatio, parseBoolean} from '../../esl-utils/misc/format';

import {ESLMediaQuery} from '../../esl-media-query/core';
import {ESLResizeObserverTarget} from '../../esl-event-listener/core';
Expand Down Expand Up @@ -101,6 +101,9 @@
@boolAttr() public playInViewport: boolean;
/** Allows to start viewing a resource from a specific time offset. */
@attr({parser: parseInt}) public startTime: number;
/** Allows player to accept focus */
@attr({parser: parseBoolean, defaultValue: ($this: ESLMedia) => $this.controls}) public focusable: boolean;


/** Preload resource */
@attr({defaultValue: 'auto'}) public preload: 'none' | 'metadata' | 'auto' | '';
Expand Down Expand Up @@ -445,5 +448,5 @@
}
export interface HTMLElementTagNameMap {
'esl-media': ESLMedia;
}

Check warning on line 451 in src/modules/esl-media/core/esl-media.ts

View workflow job for this annotation

GitHub Actions / Linting

File has too many lines (452). Maximum allowed is 450
}
2 changes: 1 addition & 1 deletion src/modules/esl-media/providers/html5/media-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export abstract class HTMLMediaProvider extends BaseProvider {
el.loop = cfg.loop;
el.muted = cfg.muted;
el.controls = cfg.controls;
el.tabIndex = 0;
el.tabIndex = cfg.focusable ? 0 : -1;
el.toggleAttribute('playsinline', cfg.playsinline);
return el;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/esl-media/providers/iframe-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class IframeBasicProvider extends BaseProvider {
el.title = this.config.title;
el.setAttribute('aria-label', this.config.title);
el.setAttribute('frameborder', '0');
el.setAttribute('tabindex', '0');
el.setAttribute('tabindex', this.config.focusable ? '0' : '-1');
el.setAttribute('scrolling', 'no');
el.setAttribute('allowfullscreen', 'yes');
el.toggleAttribute('playsinline', this.config.playsinline);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/esl-media/providers/youtube-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class YouTubeProvider extends BaseProvider {
el.title = sm.title;
el.setAttribute('aria-label', el.title);
el.setAttribute('frameborder', '0');
el.setAttribute('tabindex', '0');
el.setAttribute('tabindex', sm.focusable ? '0' : '-1');
el.setAttribute('allowfullscreen', 'yes');
return el;
}
Expand Down
Loading