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 4 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.

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;
isFocusable?: 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, isFocusable} = component;
const config = {loop, muted, controls, autoplay, title, preload, playsinline, startTime, isFocusable};
if (mediaId) Object.assign(config, {mediaId});
if (mediaSrc) Object.assign(config, {mediaSrc});
return config;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/esl-media/core/esl-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@
return PlayerStates;
}

public get isFocusable(): boolean {
return this.getAttribute('role') !== 'presentation';
}
grechihinrhp marked this conversation as resolved.
Show resolved Hide resolved

static supports(name: string): boolean {
return ESLMediaProviderRegistry.instance.has(name);
}
Expand Down Expand Up @@ -444,6 +448,6 @@
Media: typeof ESLMedia;
}
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 (453). 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.isFocusable ? 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.isFocusable ? '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.isFocusable ? '0' : '-1');
el.setAttribute('allowfullscreen', 'yes');
return el;
}
Expand Down
Loading